I'm having an issue where the text-decoration
attribute isn't working with the first-letter
specification.
In this example the purpose of the code is to style the first letter of each <div class="content">
block.
div.content:first-letter {
text-decoration: underline;
color: #bd00df;
}
The first letter of each <div class="content">
block does turn purple, but it doesn't get underlined.
How do I get it to underline in a simple and productive way?
In CSS, the ::first-letter pseudo-element applies to block-like containers such as block, list-item, table-cell, table-caption, and inline-block elements. In CSS a ::first-line pseudo-element is similar to an inline-level element if its 'float' property is 'none'; otherwise, it is similar to a floated element.
The ::first-letter selector is used to add a style to the first letter of the specified selector.
To bold the text in HTML, use either the strong tag or the b (bold) tag. Browsers will bold the text inside both of these tags the same, but the strong tag indicates that the text is of particular importance or urgency. You can also bold text with the CSS font-weight property set to “bold.”
This is a bug present in Chrome from version 36+. The text-decoration
does not render when set with :first-letter
.
Chrome has an interesting history of rendering differences for text-decoration: underline
when compared to other browsers.
These examples have the first letter set at font-size: 10em;
. I have obtained the screenshots with crossbrowsertesting.com.
You can view the full results on Chrome for OSX here and Windows 7 here
You can view the jsfiddle here.
For comparison, Firefox has these consistent results, tested from Version 7:
Even IE is more consistent.
IE 6 - 7 IE8+
These are taken from Chrome running on Mac OS 10.9 and Windows 7 64bit
Chrome Version 19 - Version 31
Single pixel underline
Chrome Version 32 - Version 33
The underline is enlarged
Chrome Version 34 - Version 35
Windows 7 64bit Mac OSX
Chrome Version 36+
Bug, no underline when set with :first-letter
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With