This one's a head scratcher.
I've created a commented jsFiddle to demonstrate the phenomenon I recently encountered while using Twitter's Bootstrap framework to create some dropdown buttons.
http://jsfiddle.net/jackwanders/WKvPv/
Basically, when using an HTML5, HTML 4 Strict or XHTML Strict DOCTYPE, the button renders as designed. However, when using an HTML4 or XHTML Transitional DOCTYPE, the caret button renders with a shorter height. Here's the relevant CSS from Bootstrap for the <span class="caret">
(i've removed styles that don't matter, like colors and gradients):
.caret {
display: inline-block;
width: 0;
height: 0;
vertical-align: top;
border-top: 4px solid #000000;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
content: "";
}
.btn .caret {
margin-top: 7px;
margin-left: 0;
}
.btn {
display: inline-block;
*display: inline;
padding: 4px 10px 4px;
margin-bottom: 0;
*margin-left: .3em;
line-height: 18px;
*line-height: 20px;
text-align: center;
vertical-align: middle;
}
Why does the DOCTYPE affect the height of the button? If line-height
is set to 18px, why would the height be less than 18px?
PS - Yes, I'm aware that Bootstrap requires HTML5, but I'd imagine that's with respect to the HTML5 features utilized, not how the DOCTYPE renders CSS styles