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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:36:53+00:00 2026-06-06T16:36:53+00:00

I took a page whose DTD was HTML4 Transitional and changed the doctype to

  • 0

I took a page whose DTD was HTML4 Transitional and changed the doctype to <!DOCTYPE html> and extra space appeared between the h1 and div beneath it. I didnt make ANY other changes to markup or CSS.

JSFiddle example: http://jsfiddle.net/ngordon/vSqkg/3/.

If you change the doctype from HTML5 to HTML4 Transitional, you can see the extra space appear and disappear even though the markup and CSS is exactly the same.

Any idea how to get rid of that space?

  • 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-06T16:36:54+00:00Added an answer on June 6, 2026 at 4:36 pm

    The HTML 4.01 Transitional doctype causes Almost Standards mode in browsers. The HTML5 doctype causes Standards mode.

    This Microsoft article explains the difference: http://msdn.microsoft.com/en-us/library/ff405794%28v=vs.85%29 .

    It says that for Almost Standards mode:

    Inline elements contribute to line height if and only if one of the
    following is true.

    If the element:

    • Contains text characters

    • Has a nonzero border width

    • Has a nonzero margin

    • Has a nonzero padding

    • Has a background image

    • Has vertical-align set to a value other than baseline

    Note that a line break is not considered a text character for this
    definition unless it is the only content of a line box. In that case,
    the line box height remains the uppermost inline box top and the
    lowermost inline box bottom on the line, regardless of the specified
    line height.

    If an img element is the sole content of a table cell, the line box
    height of the cell line box height is adjusted to zero.

    Most critically in your case, it means that the calculation of the height of the line containing the image doesn’t include the strut, an imaginary inline element that should increase the line height to the line-height value of the h1 element.

    This jsfiddle shows a real span element with an &nbsp; as real text content standing in for the strut, and you can see that the layout is the same with both an HTML 4.01 Transitional doctype and an HTML5 doctype.

    This jsfiddle shows the same idea, only this time the strut is fabricated using CSS, like this:

    h1:before {
       content: '\A0';
    }
    

    In the case of khurram’s answer, what he is doing is reducing the line-height of the h1 and hence, in standards mode, the height of the strut to be less than the height of the image. This means that the height of the line as a whole is determined by the height of the image, not the height of the strut. The height of the image is the same in both standards and almost standards mode so again, you don’t see a difference in rendering between the modes.

    As for why setting the line-height of the h1 to match the height of the image (25px) doesn’t work but setting it to 12px does, that’s because the strut establishes not only a top and a bottom, but also a baseline for the line. The baseline is a little above the bottom to allow for text descenders, for normal size text that’s usually about 3px. The image by default sits on the baseline so the gap between the baseline and the bottom is added to the height of image to establish the height of the line.

    This can be resolved by moving the image off the baseline, by using img { vertical-align: top }, which is shown in this jsfiddle. If you tinker with the h1 line-height here, you will see that values greater than 25px increase the spacing between the lines, but values of 25px or less do not change that spacing.

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

Sidebar

Related Questions

I want to display a This page took x seconds widget at the bottom
I took the rendered page from the SWT Browser and exported it to an
I took the following code from the examples page on Asio class tcp_connection :
I took the example code from the Kendo UI demos at http://demos.kendoui.com/web/grid/remote-data.html , binding
I took over an old HTML based site with all hard coded links, no
iam using leigeber's sorting javascript to sort my data on my page......i took the
I'm looking for a way to track how long it took for a page
I recently took my Db initiating code out of the __construct of my Page
I'm posting to a web page which I was told took XML as it's
I have an HTML page as follows Lorem Ipsum is simply dummy text of

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.