Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7734279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:12:37+00:00 2026-06-01T07:12:37+00:00

In the following HTML page, I have a div, which contains two spans (

  • 0

In the following HTML page, I have a div, which contains two spans (span1 and span2), the second of which contains a sub-span, span2a. The span1 contains text, as does the span2a. With this setup, the vertical alignment of the text differs, and I can’t work out why.

To complicate matters, there are style attributes on the span2 and span2a. I have no control over these, as they’re injected at runtime by the jQuery cycle plugin.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Test</title> 
    <style type="text/css">
        body {margin: 0; padding: 0; font-family: arial; color: black;}
        .container { height: 30px; text-align: left; padding: 8px 15px 0 15px; background-color: #fee; border: 1px solid red;}
        .ticker { font-size: 12px; font-weight: bold; padding-top: 4px; float: left;}
        .ticker > span:first-child { background-color: #bfb; }
        .tickerscroll { display: inline-block; background-color: #bbf; }
    </style>
</head>
<body>
    <div class="container">
        <div class="ticker">
            <span class="span1">LABEL: </span>
            <span class="span2 tickerscroll" style="position: relative; width: 480px; height: 15px; overflow-x: hidden; overflow-y: hidden; ">
                <span class="span2a" style="position: absolute; top: 0px; opacity: 1; z-index: 3; left: 0px; ">The value (in a sub-span; note that Label is lower then this text)</span>
            </span>
        </div>
    </div>
    <div class="container">
        <div class="ticker">
            <span class="span1">LABEL: </span>
            <span class="span2 tickerscroll" style="position: relative; width: 480px; height: 15px; ">
                &nbsp;<span class="span2a" style="position: absolute; top: 0px; left: 0px; ">The value (this time, I've added a &amp;nbsp; outside this inner span)</span>
            </span>
        </div>
    </div>
    <div class="container">
        <div class="ticker">
            <span class="span1">LABEL: </span>
            <span class="span2 tickerscroll" style="position: relative; width: 480px; height: 15px; ">
                The value (this time, the inner span span2a is not present at all)
            </span>
        </div>
    </div>
</body>
</html>

As you can see from my code, I’ve added two variants which “fix” the issue:

  1. Add some text (any text, in my case I’ve added a non-breaking space) inside the span2 outside of span2a.
  2. Remove the sub-span altogether, and have the text just inside the second top-level span. However, this isn’t an option for me, as the presence of span2a is required to make the jQuery cycling work.

Is there a way to make the two pieces of text aligned the same without having to artifically throw a &nbsp; into span2? The solution cannot change the style attributes of any of the span elements, but can add CSS classes if necessary.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T07:12:38+00:00Added an answer on June 1, 2026 at 7:12 am

    The vertical align is different because span tags are naturally inline elements, in your case you are modifying that behavior on your span2 class by creating a block-level element with your overflow:hidden property. You can fix it by defining your span1 class also as a block-level element with display:inline-block and simply aligning it to the top with the vertical-align:top property or floating it to the left:

    .span1 {
        display: inline-block;
        *display:inline; /* ie 7 fix */
        vertical-align: top;
    }
    

    Or

    .span1 {
        float:left;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login page using jQuery Mobile which contains the following code: <div
I have written a HTML page which has following code. <div id=adsListContainer style=margin: 5px;>
I have the following HTML on my page: <div id=mypanel> <span>SomeText</span> <span>SomeText2</span> <span>SomeText3</span> <span>SomeText4</span>
I have the following HTML on a Jquery Mobile Page: <div data-role=controlgroup data-type=horizontal class=panelSwitcher>
in my html page, I have the following: <div id=rub> Select at least one
I have the following elements in a HTML page: <body> <div style=height:100%; width:100%> <div
I have the following jQueryMobile page anatomy at index.html: <div data-role=page> <div data-role=header>...</div> <div
I have the following html page: <div id=a onclick =javascript:click();>a</div> <div id=b onclick =javascript:click();>b</div>
I have this html page which globally exists of div , section , and
I have a php page which contains a large amount of HTML in it.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.