Contents

Text Formatting

HTML Formatting elements

Text formatting is an essential part of creating web content, as it helps structure and emphasize important information on a webpage. HTML provides various tags to format text, including paragraphs, headings, bold or italic text, and quotations. In this guide, we’ll explore the most commonly used text formatting tags in HTML.

Paragraphs ( < p >)

The <p> tag is used to define paragraphs. It automatically adds spacing before and after the paragraph, helping to separate blocks of text.

Example:

				
					<p>This is a paragraph of text. HTML makes it easy to create well-structured web content.</p>

				
			

This tag is ideal for grouping sentences and creating readable blocks of content.

Paragraphs ( < h1 > to < h6 >)

Headings are used to define the structure of content, with <h1> being the highest level (used for main titles) and <h6> the lowest (used for smaller subheadings).

Example:

				
					<h1>This is a Main Heading</h1>
<h2>This is a Subheading</h2>
<h3>This is a Sub-subheading</h3>

				
			
  • <h1>: Most important heading (used for page titles).
  • <h2>: Subheading (used for sections or major topics).
  • <h3> to <h6>: Used for further subdivisions within sections.

 

Headings are essential for both visual structure and SEO, as search engines use headings to understand the hierarchy of content.

Text Formatting Tags

HTML offers various text formatting tags to emphasize or style content within a paragraph or other elements. Here’s a look at the most commonly used formatting tags:

  • Bold Text (<b> and <strong>)

    • <b>: Renders text in bold without adding semantic meaning.
    • <strong>: Renders text in bold and also implies strong importance.
     

    Example:

				
					<p>This is <b>bold text</b> without importance.</p>
<p>This is <strong>important bold text</strong> with semantic meaning.</p>


				
			
  • Italic Text (<i> and <em>)

    • <i>: Renders text in italics but without extra emphasis.
    • <em>: Renders text in italics and also implies emphasis.
     

    Example:

				
					<p>This is <i>italic text</i> without emphasis.</p>
<p>This is <em>emphasized italic text</em> with meaning.</p>


				
			
  • Underlined Text (<u>)

    The <u> tag underlines the text.

    Example:

				
					<p>This is <u>underlined text</u>.</p>

				
			
  • Small Text (<small>)

    The <small> tag renders text in a smaller size.

    Example:

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

				
			
  • Marked Text (<mark>)

    The <mark> tag highlights text by adding a background color (usually yellow).

    Example:

				
					<p>This is <mark>highlighted text</mark>.</p>

				
			
  • Deleted and Inserted Text (<del> and <ins>)

    • <del>: Displays text with a strikethrough, indicating that it has been deleted.
    • <ins>: Displays text with an underline, indicating newly inserted text.

    Example:

				
					<p>This text was <del>deleted</del> but this text is <ins>inserted</ins>.</p>

				
			
  • Subscript and Superscript (<sub> and <sup>)

    • <sub>: Displays text in subscript (useful for chemical formulas, mathematical expressions).
    • <sup>: Displays text in superscript (useful for exponents, ordinal numbers).

    Example:

				
					<p>Water's chemical formula is H<sub>2</sub>O.</p>
<p>E = mc<sup>2</sup> is Einstein's famous equation.</p>

				
			

Quotations and Citations

HTML provides special tags for quoting text and referencing external sources.

  • Blockquote (<blockquote>)

    The <blockquote> tag is used for long, block-level quotations. Typically, it indents the quoted text.

    Example:

				
					<blockquote>
  "The only limit to our realization of tomorrow is our doubts of today." 
  — Franklin D. Roosevelt
</blockquote>

				
			

Blockquotes are useful for longer quotes that stand alone as a separate block of content.

  • Inline Quote (<q>)

    The <q> tag is used for shorter, inline quotes. It typically adds quotation marks around the text.

    Example:

				
					<p>He said, <q>The journey of a thousand miles begins with a single step.</q></p>

				
			
  • Citations (<cite>)

    The <cite> tag is used to reference the title of a work, such as a book, website, or research paper. The text is usually italicized.

    Example:

				
					<p>The book <cite>To Kill a Mockingbird</cite> is a classic of American literature.</p>

				
			

Summary

Text formatting in HTML allows you to structure and emphasize content using a variety of tags. Paragraphs (<p>) and headings (<h1> to <h6>) organize the document into readable sections, while formatting tags like <b>, <i>, <u>, and <strong> help add emphasis to specific parts of the text. Quotation tags like <blockquote> and <q> make it easy to include quotes, while <cite> provides a way to properly cite sources. These tools are essential for creating well-structured and visually appealing web pages that are also accessible and meaningful for users and search engines.