HTML5: How to define subscripted text?
Solution:
HTML Code:
<!DOCTYPE html><!-- Define document type as HTML -->
<html><!-- Begin HTML document -->
<head><!-- Start of document header -->
<meta charset="utf-8"><!-- Define character encoding -->
<title>How to define subscripted text</title><!-- Title of the HTML page -->
</head><!-- End of document header -->
<body><!-- Start of document body -->
<p>This text is<sub>subscript</sub> text.example- H<sub>2</sub>O </p><!-- Paragraph element containing subscripted text -->
</body><!-- End of document body -->
</html><!-- End of HTML document -->
Explanation:
- This HTML code defines a webpage with a paragraph containing subscripted text.
- The <sub> tag is used to define subscripted text within the paragraph.
- The text "subscript" inside the <sub> tags will be displayed in a smaller font size and lowered position compared to the surrounding text.
- The text "H<sub>2</sub>O" demonstrates the use of subscript for chemical formulas, where "2" is displayed in subscript.
Live Demo:
See the Pen style-type-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.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/html-css-exercise/basic/sub-answer.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics