codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🎨

HTML & CSS

5 / 59 topics
1Introduction to HTML2HTML Elements3HTML Attributes4HTML Document Structure5HTML Text Formatting6HTML Links7HTML Images8HTML Lists9HTML Tables10HTML Forms
Tutorials/HTML & CSS/HTML Text Formatting
🎨HTML & CSS

HTML Text Formatting

Updated 2026-04-20
3 min read

Introduction

HTML (Hypertext Markup Language) is the backbone of web development, providing a way to structure and present content on the web. One fundamental aspect of HTML is text formatting, which allows developers to control how text appears on their websites. This tutorial will cover various HTML tags used for text formatting, including headings, paragraphs, lists, emphasis, and line breaks.

Headings

Headings are used to define titles or subtitles within your content. HTML provides six levels of headings, ranging from <h1> (the highest level) to <h6> (the lowest level). Each heading tag is semantically significant and should be used in a hierarchical order.

Example:

<h1>Main Heading</h1>
<h2>Sub Heading</h2>
<h3>Sub-sub Heading</h3>

Best Practices:

  • Use headings to create a logical structure for your content.
  • Ensure that the hierarchy of headings is clear and consistent throughout your document.

Paragraphs

Paragraphs are defined using the <p> tag. They represent blocks of text separated by whitespace in the HTML source code.

Example:

<p>This is a paragraph of text.</p>
<p>Here's another paragraph with some <strong>bold</strong> and <em>italic</em> text.</p>

Best Practices:

  • Use <p> tags for blocks of text to ensure proper spacing and readability.
  • Avoid using multiple consecutive <br> tags to create space; instead, use CSS for layout adjustments.

Lists

Lists are used to present items in an organized manner. HTML supports two types of lists: ordered (<ol>) and unordered (<ul>).

Ordered List:

<ol>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ol>

Unordered List:

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

Best Practices:

  • Use ordered lists when the order of items is important.
  • Use unordered lists for collections where the order does not matter.

Emphasis

HTML provides tags to emphasize text, making it bold or italic. These tags are <strong> and <em>, respectively.

Example:

<p>This is a <strong>bold</strong> word.</p>
<p>This is an <em>italic</em> word.</p>

Best Practices:

  • Use <strong> for text that needs strong emphasis, as it also conveys importance semantically.
  • Use <em> for text that should be emphasized but not necessarily more important.

Line Breaks

To insert a line break within a paragraph, use the <br> tag. This is useful when you want to preserve line breaks in poetry or addresses.

Example:

<p>This is line one.<br>This is line two.</p>

Best Practices:

  • Use <br> sparingly and only where necessary for layout purposes.
  • Avoid using multiple consecutive <br> tags; consider using CSS for more complex layouts.

Horizontal Rules

Horizontal rules are used to separate sections of content. They are created using the <hr> tag.

Example:

<p>This is the first section.</p>
<hr>
<p>This is the second section.</p>

Best Practices:

  • Use horizontal rules judiciously, as overuse can make your page look cluttered.
  • Consider using CSS to style horizontal rules for better visual separation.

Blockquotes

Blockquotes are used to highlight text that is quoted from another source. They are defined using the <blockquote> tag.

Example:

<blockquote>
  "The only limit to our realization of tomorrow will be our doubts of today." - Franklin D. Roosevelt
</blockquote>

Best Practices:

  • Use blockquotes for direct quotes or important statements.
  • Consider styling blockquotes with CSS to enhance their visual impact.

Preformatted Text

Preformatted text is used to display text exactly as it appears in the HTML source code, preserving spaces and line breaks. This is achieved using the <pre> tag.

Example:

<pre>
function greet() {
  console.log("Hello, World!");
}
</pre>

Best Practices:

  • Use preformatted text for displaying code snippets or other content where whitespace preservation is crucial.
  • Consider styling preformatted text with CSS to improve readability.

Conclusion

HTML provides a rich set of tags for formatting text, allowing developers to create well-structured and visually appealing web pages. By understanding and effectively using these tags, you can enhance the presentation and accessibility of your content. Remember to follow best practices for semantic HTML and responsive design to ensure that your text is both functional and aesthetically pleasing.

Additional Resources

  • MDN Web Docs - Text Formatting
  • W3Schools - HTML Text Formatting

By mastering these text formatting techniques, you'll be well-equipped to create engaging and informative web content.


PreviousHTML Document StructureNext HTML Links

Recommended Gear

HTML Document StructureHTML Links