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 8897913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:28:25+00:00 2026-06-15T00:28:25+00:00

Possible Duplicate: Can a span be closed using <span />? <p>This is a test

  • 0

Possible Duplicate:
Can a span be closed using <span />?

<p>This is a test <span id='span1' style='display:inline-block;'></span> to see if I can embed an inline block.</p>

<p>This is a test <span id='span2' style='display:inline-block;'/> to see if I can embed an inline block.</p>​

http://jsfiddle.net/T7ByE/

The first line embeds a span with a regular closing tag, while the second uses a self-closing tag. The first line works properly, while the second has a bizarre result.

I’m just curious why there is such a difference in the handling of the element in each case. I’m aware that under non-strict xhtml, self-closing tags aren’t very well supported. It appears the self-closing tag is being treated as just an open tag.

Is there a good reason modern browsers still don’t support self-closing html tags? Am I expected to change the doctype or something to get this to work?

The irony is I actually started with an explicit closing tag, but ran it through the browser’s xml parser and back to html, and the parser felt like collapsing the empty element into a self-closing tag, which promptly broke everything.

  • 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-15T00:28:26+00:00Added an answer on June 15, 2026 at 12:28 am

    Web-browsers have DOM inspectors which show us the structure of the resulting DOM tree. For instance, in Firebug:

    enter image description here

    As you can see, Firefox doesn’t recognize the self-closing tag, but treats it like a start-tag instead. Firefox will close that SPAN element automatically when it reaches the end of the paragraph, meaning that the SPAN will contain the remaining text of the paragraph.

    Now, since you’re inserting a DIV element into the SPAN element, the DIV will be laid out below the text-content of that SPAN element. This is because the DIV element is a block-level element. Block-level elements that appear after text-content, are laid out below that text-content.

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Can I comment a JSON file? We are using a .json file
Possible Duplicate: Can you animate a height change on a UITableViewCell when selected? This
Possible Duplicate: Can someone Explain this jQuery code? I have posted this before, but
Possible Duplicate: A Space between Inline-Block List Items I have a JSFiddle demo of
Possible Duplicate: Can you do Desktop Development using JavaScript? I am very familiar with
Possible Duplicate: Can I develop blackberry applications using C#.NET on windows7 can anybody give
Possible Duplicate: Can we post on Google plus from android application? According to this
Possible Duplicate: Can somebody explain this Javascript method ? (x = [].reverse)() === window
Possible Duplicate: jQuery select based on text I have something like this: <span>abc</span> <span>a</span>

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.