New issue
Advanced search Search tips

Issue 647239 link

Starred by 3 users

Issue metadata

Status: Available
Owner: ----
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Compat



Sign in to add a comment

:first-letter doesn't work as expected with :before

Reported by ryu...@gmail.com, Sep 15 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36

Example URL:
https://jsfiddle.net/8f5v60uj/1/

Steps to reproduce the problem:
1. style p:first-letter {color: red}
2. add p:before { content: '#'}

What is the expected behavior?
First-letter "#" should be red.

What went wrong?
"#" seems to not be a "letter" for chrome

Does it occur on multiple sites: N/A

Is it a problem with a plugin? No 

Did this work before? N/A 

Does this work in other browsers? Yes 

Chrome version: 52.0.2743.116  Channel: n/a
OS Version: OS X 10.11.4
Flash Version: Shockwave Flash 22.0 r0
 
Issue seems related to a TextNode only composed of a hash (#). You can workaround with a zero-width space to trick Chromium into believing that your text node exists.
Example : http://codepen.io/borisschapira/pen/rrZqvz
Components: Blink>CSS
Labels: -OS-Mac OS-All
Mac->All
+Blink>CSS

Comment 3 by sashab@chromium.org, Sep 19 2016

Labels: Hotlist-Interop
Status: Available (was: Unconfirmed)
Screenshots attached for Firefox and Chrome.

Adding Hotlist-Interop since this is clearly an interop bug. Marking as available for anyone who wants to pick this up.
Chrome.png
4.5 KB View Download
Firefox.png
4.1 KB View Download
Cc: r...@opera.com
While I agree this is an interop bug, none of the major engines seem to agree on the expected behavior, as can be seen on the screenshots:
- Blink still shows the first "#l" and all ">"s in red.
- EdgeHTML shows all the "#l"s and all ">"s in red.
- Gecko shows the first "#l" in red, all the other "#"s in red and does not change the color of any ">"s.
- WebKit shows the first "#l" in red, all other "#"s in red and all ">"s in red.

Surprisingly, according to the relevant specs all the behaviors above seem to be acceptable:
- https://drafts.csswg.org/css-pseudo-4/#generated-content says "the generated content of ::before and :after pseudo-elements may be included in any ::first-line and ::first-letter pseudo-elements applied to its originating element" ("may", not "must").
- https://drafts.csswg.org/css-pseudo-4/#first-letter-pseudo says "If the characters that would form the ::first-letter are not in the same element, such as ‘T in <p>‘<em>T..., the user agent may create a ::first-letter pseudo-element from one of the elements, both elements, or simply not create a pseudo-element".

">" is part of the "Math_Symbol" category in Unicode, so it's neither punctuation nor a typographical letter, so it could be argued that it should not have its color changed to red at all (though the spec is not very explicit in stating what to do when the first typographical letter unit is preceded by characters that are not punctuation).

I wonder if the spec needs an update or if everything is just working as intended.
chromium-m55.png
4.3 KB View Download
edgehtml-14.14393.png
2.3 KB View Download
firefox-50.png
3.0 KB View Download
webkitgtk-r210547.png
3.5 KB View Download
Labels: Update-Quarterly

Comment 6 by meade@chromium.org, Oct 31 2017

Labels: HardBug Standards
Attached a screenshot of how this looks now on Chrome 62.0.3202.62 (linux) and firefox

Adding Standards label since the correct behaviour seems ambiguous.
Screenshot from 2017-10-31 11:03:40.png
125 KB View Download
Labels: -Update-Quarterly
Project Member

Comment 8 by sheriffbot@chromium.org, Dec 6

Labels: Hotlist-Recharge-Cold
Status: Untriaged (was: Available)
This issue has been Available for over a year. If it's no longer important or seems unlikely to be fixed, please consider closing it out. If it is important, please re-triage the issue.

Sorry for the inconvenience if the bug really should have been left as Available.

For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
Cc: -r...@opera.com futhark@chromium.org
Status: Available (was: Untriaged)

Sign in to add a comment