/

HTML / CSS / JavaScript Tutorial

CSS Property: text-transform

[this page | pdf | back links]

The CSS (CSS1) text-transform property specifies the capitalisation the browser should use for text.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

capitalize

First character of each word is capitalised (i.e. transformed to uppercase)

lowercase

All characters transformed to lowercase

none

(default value). No capitalisation

uppercase

All characters transformed to uppercase

 

Default Value:

none

JavaScript syntax:

e.g. object.style.textTransform="capitalize"

Inherited:

Yes

Animatable:

No

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 100px; height: 15px; border: thin solid green;}
.x1 {text-transform: uppercase}
</style>
</head>
<body>
1. Element with default property<br>
<div>abcdefgh</div><br><br>
2. Element set using in-file HTML style<br>
<div class="x1">abcdefgh</div><br><br>
3. Element set using JavaScript<br>
<div id="x2">abcdefgh</div>

<script>
document.getElementById("x2").style.textTransform = "uppercase";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyTextTransform() {
  var x = document.createElement("DIV"); x.style.textTransform = "uppercase"; return (window.getComputedStyle(x, null).textTransform == "uppercase");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile