Whitespace Above Text In a DIV With No Padding

Posted on 2011-10-24
Last Modified: 2012-05-12
Hello Experts -
A quick 500 points for someone..  Using the following DIV and assuming no further CSS specified elsewhere, why is there whitespace between the top of the text and the top border?
<div style="border:1px solid black; height:30px; width:100px; padding:0; vertical-align:top;">Fubar</div>

Open in new window

The left edge of the text sits immediately next to the left border (as expected) but the top doesn't do the same.  Why, and how do I get rid of that whitespace?  Thanks.

-- Rick
Question by:MinnRick
    LVL 21

    Accepted Solution

    Default line-height value? Try setting a line-height equal to the font-size (or less). Some fonts have built-in white space above and below, too.

    Author Closing Comment

    That must've been it.  Adjusting the line-height worked fine.  Thanks XM.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
    In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now