Home >Web Front-end >CSS Tutorial >How Can I Capitalize the First Letter of Each Word in a Label Using CSS?

How Can I Capitalize the First Letter of Each Word in a Label Using CSS?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-07 18:45:13746browse

How Can I Capitalize the First Letter of Each Word in a Label Using CSS?

Capitalizing the Initial Character in CSS

Is it possible to capitalize the first character in a label using CSS?

HTML Sample

<a class="m_title" href="">gorr</a>
<a class="m_title" href="">trro</a>
<a class="m_title" href="">krro</a>
<a class="m_title" href="">yrro</a>
<a class="m_title" href="">gwwr</a>

CSS Solution

To achieve this, CSS provides the text-transform property:

a.m_title {
  text-transform: capitalize;
}

This property instructs the browser to capitalize the first character of each word within the m_title class.

Result

<a class="m_title" href="">Gorr</a>
<a class="m_title" href="">Trro</a>
<a class="m_title" href="">Krro</a>
<a class="m_title" href="">Yrr</a>
<a class="m_title" href="">Gwwr</a>

The above is the detailed content of How Can I Capitalize the First Letter of Each Word in a Label Using CSS?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn