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

  • Home
  • SEARCH
  • 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 6221539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:09:04+00:00 2026-05-24T08:09:04+00:00

I am having a problem getting the correct width of a span. It works

  • 0

I am having a problem getting the correct width of a span. It works in the following browsers and NOT in IE7:
Works in:
Firefox
Chrome
Safari
IE8

I need to get the correct width of the span so I can pass it as an argument to a jquery function.

Example code is identical to code with problem, but with generic class names substituted in to make the example easier to understand/refer to.

Related HTML:

...
<span class="outer-span">
 <div class="inner-div">
  <a href="http://www.google.com">
   <span class="selected">
    <c:out value="${somestring}" />
   </span>
  </a>
 </div>
</span>
...

Related CSS:

.outer-span { width: 120px; }

When I alert($(‘.outer-span’).width()) in all browsers EXCEPT IE7 I get 120.
In IE7, the alert shows me that the width of ‘outer-span’ is 700px, which is probably the width of one of its parents.

I know that to accurately reason about the problem, you probably have to see the html above the block that I’ve posted. What I’m looking for however, is some tips for debugging the problem, or a clue as to why IE7 acts this way or how IE7 handles things differently. I’m not looking for you to rewrite my code or come up with some CSS hack. Comment if you need more clarification on the problem.

  • 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-05-24T08:09:05+00:00Added an answer on May 24, 2026 at 8:09 am

    You can’t put a <div> (block element) inside a <span> (inline element). It’s invalid and doesn’t make sense.

    Browsers may try to fix your mistake, for example by closing the <span> when it sees the opening <div>. This would cause the span to be empty and hence have no width. But this behaviour will vary across browsers.

    Also, you can’t put a width on an inline element. It will have no effect, unless you have IE in Quirks Mode… which may be the case if this is working for you. You really want to avoid Quirks Mode (use a proper <!DOCTYPE>!).

    If you want a simple block wrapper to contain a <div>, it should probably also be <div>.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a problem getting a TreeView control to display node images. The code below
I am having a problem getting a list of fields from a query defined
I'm having a problem getting access to a database which lives on a remote
I am having a problem getting my project to link with the PhysX libraries
After having solved the problem of getting the editor to launch when there's a
Greetings! I'm having a problem getting a text value of a captcha from a
I'm having a problem getting emails to bounce to a specific email address, different
I'm having a problem with getting my Google Maps API key to work. I
I'm having some problem with my code. It works fine when I compile it
I am having a problem getting an old Ruby on Rails 2 app that

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.