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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:03:16+00:00 2026-05-28T08:03:16+00:00

I have an html5 page with a navbar. Completely scratch coded. I just recently

  • 0

I have an html5 page with a navbar. Completely scratch coded. I just recently added a doctype to the item, and now I’m getting extra space under my navbar. If I remove the doctype declaration, it goes back to normal. I have completely reset padding, margins, etc. on everything, and cut it down to the a small amount of code that illustrates the issue.

The page can be seen at http://hackthetruth.org/webdesign/broken

Does anyone know why declaring the doctype is messing with the height of a div?

  • 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-28T08:03:17+00:00Added an answer on May 28, 2026 at 8:03 am

    This is an interesting and subtle, yet important consideration when using inline-block.

    The short answer is: set vertical-align on your ul to anything other than baseline.

    The reason this works is that inline-blocks are considered text, and thus are subjected to text-based properties such as line-height and vertical-align.


    The longer answer is as follows:

    The CSS3 specification goes in to some (perhaps confusing) depth around how the box model works. Here’s a quote from the CSS3 box spec, in which I’ve highlighted the part that’s relevant to this problem:

    9.5. ‘Inline-block’ or floating, non-replaced elements

    … The used value of height is the computed value,
    unless that is ‘auto’, when the used value is defined by “‘Auto’
    heights for flow roots.”

    Let’s check what the auto heights for flow roots are:

    9.10. ‘Auto’ heights for flow roots

    In certain cases (see the preceding sections), the height of an
    element is computed as follows:

    • If it only has inline-level children, the height is the distance between the top of the topmost line box and the bottom of the
      bottommost line box.

    …

    The line box parts are of interest. What this effectively implies is that anything set to display as inline-block is subject to the implicit box layouts that plain text uses.

    You might be able to guess now why setting vertical-align fixes this problem, but let’s continue tracing this problem through the spec.

    The line-box definition is a little lacklustre, and the example in section 4.2 is only marginally helpful.

    Let’s go back to the CSS 2.1 spec, which does a far nicer job at explaining line boxes:

    The rectangular area that contains the boxes that form a line is called a line box … [its height] is determined by the rules given in the section on line height calculations.

    From this explanation, we see that the line-height and vertical-align properties have something to do with how the heights (of line boxes, thus inline-block elements) are calculated. Reading the calculations of line-height almost make it clear:

    …In case [line boxes] are aligned ‘top’ or ‘bottom’, they must be aligned so as to minimize the line box height.

    So our inline-block element’s height is being affected by its implicit line box’s height calculations, which are in turn subject to these vertical-alignment calculations.

    So it would seem that when we don’t use baseline as a vertical-align for an inline-block, the box’s implicit line box will shrink to the smallest size it can.

    Confusing? …Yeah. Just jump back to the shorter answer 🙂

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

Sidebar

Related Questions

I'm trying to get an html5 demo page working on Android 2.1, have tried
I have an HTML5 page loaded on server along with a geolocation script. The
I have a page with html5 drag and drop upload feature and the file
I have a nice running HTML5 Website with some JavaScript. This Page is called
I am working on a page using only html5 and jquery, and I have
I'm looking at this: http://www.netmagazine.com/tutorials/create-page-flip-effect-html5-canvas However, I have one problem with that - I
I have a simple HTML5 page that I'm building to figure some things out
How to replicate: Create an html5 page. Make sure you have the script from
I have a demo page, http://forum.tiedtheleader.com/html4.php#bottom http://forum.tiedtheleader.com/html5.php#bottom and when using IE in the Mango
I have HTML page where windows media player is embedded. It works very well

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.