CSS text-transform: Uppercase, Lowercase, and Capitalize Text

CSS text-transform changes the case you see while leaving the HTML text intact. Use uppercase for capitals, lowercase for lowercase, and capitalize for word initials. This example applies four values to the same source text.

Four values and their results

The initial value is none. capitalize changes a lowercase word initial to its titlecase form and leaves the remaining letters as written. That is why WORLD stays uppercase in hello WORLD. CSS Text · text-transform

Value Effect Rendered text
none Keeps the written case. hello WORLD
uppercase Displays uppercase letters. HELLO WORLD
lowercase Displays lowercase letters. hello world
capitalize Changes lowercase word initials and preserves other letters. Hello WORLD

Override inherited casing

The property is inherited. When a parent uses uppercase, its children inherit that value. To keep one child in its written case, set text-transform: none on that child, as shown below.

.label { text-transform: uppercase; }
.label .original-case { text-transform: none; }

Compare all values in one example

Save the code as text-transform.html and open it in a browser. The first four rows contain the same source, hello WORLD. In the last row, none on the child overrides the parent’s uppercase. The mixed-script row displays 한글 CSS, since Hangul has no case distinction.

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Compare text-transform</title>
  <style>
    body {
      margin: 0;
      color: #243449;
      background: #eef2f6;
      font-family: system-ui, sans-serif;
      line-height: 1.7;
    }
    main { max-width: 760px; margin: 24px auto; padding: 0 20px; }
    h1 { font-size: 26px; }
    .row { padding: 12px 16px; margin: 12px 0; background: white; }
    .label { display: block; color: #52677d; font-size: 14px; }
    .value { font-size: 26px; overflow-wrap: anywhere; }
    .none { text-transform: none; }
    .upper { text-transform: uppercase; }
    .lower { text-transform: lowercase; }
    .capital { text-transform: capitalize; }
  </style>
</head>
<body>
  <main>
    <h1>Compare uppercase and lowercase</h1>
    <p class="row"><span class="label">none</span>
      <span id="none" class="value none">hello WORLD</span></p>
    <p class="row"><span class="label">uppercase</span>
      <span id="upper" class="value upper">hello WORLD</span></p>
    <p class="row"><span class="label">lowercase</span>
      <span id="lower" class="value lower">hello WORLD</span></p>
    <p class="row"><span class="label">capitalize</span>
      <span id="capital" class="value capital">hello WORLD</span></p>
    <p class="row"><span class="label">Hangul mixed with Latin text</span>
      <span id="mixed" class="value upper" lang="ko">한글 css</span></p>
    <p class="row"><span class="label">Turkish uppercase</span>
      <span id="turkish" class="value upper" lang="tr">istanbul</span></p>
    <p class="row upper"><span class="label none">Override inherited casing</span>
      <span id="reset" class="value none">hello WORLD</span></p>
  </main>
</body>
</html>

Language rules and the limits of capitalize

In Turkish, lowercase i maps to dotted uppercase İ. The row tagged lang="tr" displays İSTANBUL. For comparison, change the element’s lang to en to get ISTANBUL, then restore tr for Turkish text.

capitalize does not apply editorial rules for English titles, such as keeping certain articles or prepositions lowercase. Write the intended case in the source when capitalization affects the meaning of an acronym or name. Apply visual changes where needed, such as menus or short labels.

Distinguish display from data conversion

Read the uppercase sample’s textContent in developer tools and you will still get hello WORLD. To change a value used in search or stored on a server, do the conversion where your code handles that value. See how to convert the case of a JavaScript string.