Capitalize first letter of sentences CSS

前端 未结 4 1229
面向向阳花
面向向阳花 2020-12-03 06:34

I want to capitalize the first letter of sentences, and also the first letter after commas if possible. I want to add the code in here:



        
4条回答
  •  感动是毒
    2020-12-03 07:17

    This cannot be done in CSS. The text-transform property makes no distinction according to the placement of a word inside the content, and there is no pseudo-element for selecting the first word of a sentence. You would need to have real elements, in markup, for each sentence. But if you can do that, then you could probably just as well change the initial letters to uppercase in the content proper.

    Capitalization at the start of a sentence is a matter of orthography and should be done when generating the content, not with optional stylistic suggestions (CSS) or with client-side scripting. The process of recognizing sentence boundaries is far from trivial and cannot in general be performed automatically without complex syntactic and semantic analysis (e.g., an abbreviation ending with a period may appear inside a sentence or at the end of a sentence).

提交回复
热议问题