HTML Programming Language

HTML Tutorial

HTML Formatting - HTML Tutorials

HTML Formatting

Understanding HTML formatting is crucial for anyone involved in web development or content creation.

Take a look at all the topics that are discussed in this article:

In this article, we’ll explore the fundamental elements of HTML formatting and how they contribute to creating visually appealing and well-organized web pages.

Bold Text

To create bold text in HTML, you can use the <strong> tag or the <b> tag. Both tags are used to indicate that the enclosed text should be rendered with a stronger emphasis, typically displayed as bold. Here’s an example:

				
					<p>This is <strong>bold text</strong> using the strong tag.</p>
<p>This is <b>bold text</b> using the b tag.</p>

				
			

Italic Text

To create italic text in HTML, you can use the <em> tag or the <i> tag. Both tags are used to indicate that the enclosed text should be rendered in italic style. Here’s an example:

				
					<p>This is <em>italic text</em> using the em tag.</p>
<p>This is <i>italic text</i> using the i tag.</p>

				
			

Underlined Text

In HTML, you can use the <u> tag to create underlined text. However, it’s worth noting that the use of underlined text for general content is somewhat discouraged in modern web design, as underlining is commonly associated with hyperlinks. Instead, other styling options like color or bold/italic emphasis are often used for non-link text.

Here’s an example of how to create underlined text:

				
					<p>This is <u>underlined text</u> using the u tag.</p>
				
			

Strike Text

To create strikethrough text in HTML, you can use the <s> tag or the <strike> tag. Both tags are used to indicate that the enclosed text should be rendered with a strikethrough line. Here’s an example:

				
					<p>This is <s>strikethrough text</s> using the s tag.</p>
<p>This is <strike>strikethrough text</strike> using the strike tag.</p>

				
			

Monospaced Font

To create monospaced or fixed-width text in HTML, you can use the <code> tag or the <pre> tag. Both tags are commonly used for displaying code snippets, computer output, or any text where maintaining a fixed-width font is important. Here’s how you can use each:

Using <code> tag:

				
					<p>This is <code>monospaced text</code> using the code tag.</p>
				
			

Using <pre> tag:

				
					<pre>This is monospaced text using the pre tag.</pre>
				
			

Note: <tt> The <tt> tag is an HTML element that stands for “Teletype Text”. It is used to display text in a monospaced font, similar to the <code> tag. However, the <tt> tag is an obsolete element and should not be used in modern HTML. It has been deprecated in HTML5 and might be removed from future versions of the HTML standard.

Superscript Text

To create superscript text in HTML, you can use the <sup> tag. The </sup> tag is used to define superscript text, which is text that appears above the regular baseline. This is commonly used for notations such as exponents or footnotes. Here’s an example:

				
					<p>This is superscript text<sup>2</sup>.</p>
				
			

Subscript Text

To create subscript text in HTML, you can use the <sub> tag. The </sub> tag is used to define subscript text, which is text that appears below the regular baseline. This is commonly used for notations such as chemical formulas or footnotes. Here’s an example:

				
					<p>This is subscript text<sub>2</sub>.</p>
				
			

Inserted Text

To represent inserted text (text that has been added) in HTML, you can use the <ins> tag. The </ins> tag is used to indicate content that has been inserted into a document. Here’s an example:

				
					<p>This is <ins>inserted text</ins>.</p>
				
			

Deleted Text

To represent deleted or removed text in HTML, you can use the <del> tag. The <del> tag is used to indicate content that has been deleted or removed from a document. Here’s an example:

				
					<p>This is <del>deleted text</del>.</p>
				
			

Larger Text

To create larger text in HTML, you can use the <big> tag or use CSS to set the font size. Here’s an example using the <big> tag:

				
					<p>This is <big>larger text</big>.</p>
				
			

Smaller Text

To create smaller text in HTML, you can use the <small> tag or use CSS to set the font size. Here’s an example using the <small> tag:

				
					<p>This is <small>smaller text</small>.</p>
				
			

Grouping Content

In HTML, you can use the <div> and <span> elements to group content and apply styles or structure to specific sections of your document.

1. <div> Element:

The <div> (division) element is a block-level container that is often used to group and apply styles to sections of content.

				
					<div>
  <p>This is a paragraph inside a div.</p>
  <ul>
    <li>Item 1</li>
    <li>Item 2</li>
  </ul>
</div>

				
			

2. <span> Element:

The <span> element is an inline container that is useful for applying styles or scripting to a specific part of text.

				
					<p>This is <span style="color: red;">red text</span> inside a paragraph.</p>
				
			

HTML formatting is the key to creating visually appealing, well-organized, and accessible web pages. By mastering these fundamental HTML elements, developers and content creators can effectively structure content, enhance user experience, and contribute to the overall aesthetics of the web.

As web technologies evolve, understanding and implementing HTML formatting remains a timeless skill in the realm of digital communication.

Categories