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 set the font size for different HTML elements</title><!-- Sets the title of the document -->
<style type="text/css"> /* Starts CSS styling */
p { /* Targets paragraph elements */
font-size: 100%; /* Sets the font size of paragraphs to 100% of the parent element's font size */
}
h1 { /* Targets h1 elements */
font-size: 250%; /* Sets the font size of h1 elements to 250% of the parent element's font size */
}
h2 { /* Targets h2 elements */
font-size: 200%; /* Sets the font size of h2 elements to 200% of the parent element's font size */
}
</style><!-- Ends CSS styling -->
</head>
<body>
<p><strong>w3resource Tutorial</strong></p><!-- Paragraph element with strong (bold) text -->
<p>This is a paragraph.</p><!-- Paragraph element -->
<h1>This is heading 1</h1><!-- h1 heading element -->
<h2>This is heading 2</h2><!-- h2 heading element -->
</body>
</html><!-- Ends the HTML document -->
Explanation:
Live Demo:
See the Pen font-size-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4