-
Notifications
You must be signed in to change notification settings - Fork 756
Description
This was a bit of an aside in a comment at the bottom of #5244, but on reflection it warrants its own issue.
The initial-letter-align property sets the top/bottom alignment points to use from the paragraph - these are matched to the top/bottom of alignment points in the initial-letter itself. The default value is "alphabetic" with the option of setting "ideographic" or "hanging" - but the user-agent stylesheet chooses a default based on the language tag of the paragraph.
This issue is to suggest the addition of an "auto" value, which would be the default.
This would effectively resolve as one of the existing values based on the script property of the first characters of the paragraph following the initial-letter itself. Characters with "Common", "Unknown" or "Inherited" scripts are skipped over until we find a character with a "strong" script - then,
- if the script is Han, Hangul, Kana, or Yi, treat as
initial-letter-align: ideographic - if the script is Devanagari, Gurmukhi or Bengali, treat as
initial-letter-align: hanging - otherwise treat as
initial-letter-align: alphabetic
(I'm presuming that "hebrew" will go away shortly as agreed)
So for example:
p {
initial-letter-align: auto
}
p::first-letter {
initial-letter: 2;
}<p>Bananas</p>
<p>A "Big" Apple</p>
<p>2月14日</p>
<p>हिन्दी</p>
<p>2345</p>
<p>2<span style="float: right">float</span> more text</p>Would result in:
- Initial letter is "B", followed by a "a"; "a" is Latin script, so "alphabetic" alignment is used
- Initial letter is "A", followed by a space and a quote, both of which are skipped as the script is common. The next letter is "B"; again "alphabetic" alignment is used
- Initial letter is 2, followed by a 月 so "ideographic" alignment is used
- Inital letter is the grapheme हि, followed by न्दी which is Devanagari script - "hanging" alignment is used
- Initial letter is 2, followed by "345" which are all common script. In the absence of any better information, the current default of "alphabetic" is used.
- Initial letter is 2, followed by out-of-flow content. The two options here would be to skip the float entirely and find the first in-flow text following it ("more text"), or just collapse to alphabetic. We could also give user agents the choice, much like we do with the
::first-letterpseudo-element when determining whether to group text following an initial punctuation character as part of the first-letter or not.
This has quite a few advantages.
- It's future proof
- It doesn't depend on correct language tagging
- It doesn't need special handling in the user-agent stylesheet (a list of rules that must inevitably grow)
- The same approach of "sniffing" the script from the glyph is already used for the initial-letter itself.
(I've tagged as css-inline-3 but I'm aware @fantasai is labouring to get that out the door. If this is approved, it makes no difference to me if it's pushed to css-inline-4)