Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

:first-letter text-decoration browser support

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?

like image 681
Seth Taddiken Avatar asked Aug 31 '14 07:08

Seth Taddiken


People also ask

Can I use CSS first letter?

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.

How do I target the first letter in CSS?

The ::first-letter selector is used to add a style to the first letter of the specified selector.

How do I make the first letter bold in HTML?

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.”


1 Answers

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.

Firefox is consistent

For comparison, Firefox has these consistent results, tested from Version 7:

Firefox screenshot

Internet Explorer

Even IE is more consistent.

IE 6 - 7                                             IE8+

Screenshot  IE 6 - 7         Screenshot IE8+

Chrome is different

These are taken from Chrome running on Mac OS 10.9 and Windows 7 64bit

Chrome Version 19 - Version 31

Single pixel underline

Screenshot 1

Chrome Version 32 - Version 33

The underline is enlarged

Screenshot 2

Chrome Version 34 - Version 35

Windows 7 64bit                                 Mac OSX

Screenshot 2Screenshot 3

Chrome Version 36+

Bug, no underline when set with :first-letter.

Screenshot 4

like image 69
misterManSam Avatar answered Oct 01 '22 16:10

misterManSam