Skip to content

[css-text] text-transform capitalize for words separated by periods only (no space) #8031

@karlcow

Description

@karlcow

Enter in the URL bar of a browser:

data:text/html,<!doctype html><div style="text-transform:capitalize">what.should.we.do</div>

Both Safari and Firefox returns:

What.should.we.do

While chrome returns:

What.Should.We.Do

The spec unfortunately seems to say that this is implementation dependent:
in https://drafts.csswg.org/css-text/#text-transform-mapping

For capitalize, what constitutes a “word“ is UA-dependent; [UAX29] is suggested (but not required) for determining such word boundaries. Out-of-flow elements and inline element boundaries must not introduce a text-transform word boundary and must be ignored when determining such word boundaries.

in https://www.unicode.org/reports/tr29/tr29-41.html

The goal of matching user perceptions cannot always be met exactly because the text alone does not always contain enough information to unambiguously decide boundaries. For example, the period (U+002E FULL STOP) is used ambiguously, sometimes for end-of-sentence purposes, sometimes for abbreviations, and sometimes for numbers. In most cases, however, programmatic text boundaries can match user perceptions quite closely, although sometimes the best that can be done is not to surprise the user.

There is an issue about this on https://bugs.chromium.org/p/chromium/issues/detail?id=1266835

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions