HTML – Text Formatting

HTML – Text Formatting

HTML provides a variety of text formatting elements to style and structure the text content of a web page. Here are some common HTML text formatting elements:

  1. Headings:
    • <h1><h2><h3><h4><h5><h6>: Represent the hierarchy of headings on the page, with <h1> being the most important and <h6> being the least important.
  2. Paragraphs:
    • <p>: Defines a paragraph of text.
  3. Text Styles:
    • <b>: Renders the text in bold.
    • <i>: Renders the text in italics.
    • <u>: Underlines the text.
    • <strong>: Indicates strong importance, often rendered in bold.
    • <em>: Indicates emphasis, often rendered in italics.
  4. Lists:
    • <ul> (Unordered List): Creates a bulleted list.
    • <ol> (Ordered List): Creates a numbered list.
    • <li> (List Item): Represents an item in a list.
  5. Links:
    • <a href="URL">Link Text</a>: Creates a hyperlink to another web page or section.
  6. Preformatted Text:
    • <pre>: Preserves the original formatting of the text, including whitespace and line breaks.
  7. Quotations:
    • <blockquote>: Represents a long quotation or block of quoted text.
    • <q>: Represents a short inline quotation.
  8. Abbreviations and Acronyms:
    • <abbr title="Explanation">Abbreviation</abbr>: Defines an abbreviation or acronym, with the full explanation provided in the title attribute.
  9. Code and Computer Output:
    • <code>: Represents a piece of computer code or output.
    • <kbd>: Represents keyboard input or a keyboard command.
    • <samp>: Represents sample output from a computer program.

Here’s an example of how these text formatting elements can be used:

html

<h1>Welcome to my website</h1>
<p>This is a <b>bold</b> and <i>italic</i> paragraph of text.</p>
<ul>
<li>Unordered list item 1</li>
<li>Unordered list item 2</li>
</ul>
<ol>
<li>Ordered list item 1</li>
<li>Ordered list item 2</li>
</ol>
<a href="https://www.example.com">Visit Example.com</a>
<pre>
This is preformatted text
that preserves line breaks
and whitespace.
</pre>
<blockquote>
<p>This is a long quotation that will be indented.</p>
</blockquote>
<p>The person said, <q>This is a short inline quotation.</q></p>
<p>The <abbr title="World Wide Web">WWW</abbr> is an important part of the internet.</p>
<code>console.log('Hello, world!');</code>
<kbd>Ctrl + S</kbd>
<samp>This is sample output from a computer program.</samp>

This example demonstrates how various HTML text formatting elements can be used to structure and style the text content of a web page.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *