About Lesson
HTML provides various tags and attributes to format and style text within web pages. Here are some commonly used HTML text formatting elements:
<strong>
: Specifies strong importance or emphasis. By default, it renders text in bold.
<p>This is <strong>important</strong> text.</p>
<em>
: Represents emphasized text. By default, it renders text in italics.
<p>This is <em>emphasized</em> text.</p>
<u>
: Underlines text.
<p>This is <u>underlined</u> text.</p>
<s>
: Renders text with a strikethrough effect.
<p>This is <s>strikethrough</s> text.</p>
<sub>
: Renders text as subscript, appearing slightly below the baseline.
<p>This is H<sub>2</sub>O.</p>
<sup>
: Renders text as superscript, appearing slightly above the baseline.
<p>This number is 10<sup>2</sup>.</p>
<mark>
: Highlights text with a background color to indicate relevance or significance.
<p>This is <mark>highlighted</mark> text.</p>
<small>
: Renders text in a smaller font size, typically used for disclaimers or fine print.
<p>This is <small>smaller</small> text.</p>
<code>
: Represents computer code or inline code snippets.
<p>Use the <code>print()</code> function to display output.</p>
<pre>
: Preserves white space and renders text exactly as it appears in the HTML code, useful for displaying code blocks or preformatted text.
<pre>
function greet() {
console.log("Hello, World!");
}
</pre>
These elements can be combined with other HTML elements to format and style text according to your specific requirements. It’s important to use these elements semantically, meaningfully, and in accordance with their intended purposes to maintain accessibility and semantic structure within your web pages.
Join the conversation