CSS Properties: How to change cases of text in paragraphst
Solution:
HTML Code:
<!DOCTYPE html><!-- Declares the document type and version of HTML -->
<html><!-- Begins the HTML document -->
<head><!-- Contains metadata and links to external resources -->
<title>How to change cases of text in paragraphs</title><!-- Sets the title of the document -->
<style type="text/css"> /* Starts CSS styling */
p.capitalize { /* Styles paragraphs with the class "capitalize" */
text-transform: capitalize; /* Transforms text to capitalize the first character of each word */
}
p.uppercase { /* Styles paragraphs with the class "uppercase" */
text-transform: uppercase; /* Transforms text to uppercase */
}
p.lowercase { /* Styles paragraphs with the class "lowercase" */
text-transform: lowercase; /* Transforms text to lowercase */
}
</style><!-- Ends CSS styling -->
</head><!-- Ends the head section -->
<body><!-- Begins the body of the document -->
<h1><strong>w3resource Tutorial</strong></h1><!-- Displays a level 1 heading with bold text "w3resource Tutorial" -->
<h3>Text transform: capitalize</h3><!-- Displays a level 3 heading indicating the text transformation -->
<p class="capitalize">web development tutorial </p><!-- Displays a paragraph with the class "capitalize" and applies text capitalization -->
<h3>Text transform: uppercase</h3><!-- Displays a level 3 heading indicating the text transformation -->
<p class="uppercase">web development tutorial </p><!-- Displays a paragraph with the class "uppercase" and applies text uppercase -->
<h3>Text transform: lowercase</h3><!-- Displays a level 3 heading indicating the text transformation -->
<p class="lowercase">web development tutorial </p><!-- Displays a paragraph with the class "lowercase" and applies text lowercase -->
</body><!-- Ends the body section -->
</html><!-- Ends the HTML document -->
Explanation:
- This HTML document demonstrates how to change the case of text in paragraphs using CSS.
- Three CSS classes (capitalize, uppercase, and lowercase) are defined to apply different text transformations.
- CSS comments are added to explain each section of the code.
- The text-transform property is used to transform the text to capitalize, uppercase, or lowercase according to the specified class.
Live Demo:
See the Pen text-transform-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics