HTML Text Formatting
HTML (Hypertext Markup Language) provides various elements and attributes for formatting text and controlling how text is displayed on a web page. Here are some common HTML text formatting options:
<h6>): HTML offers six levels of headings, ranging from
<h1>(the highest level) to
<h6>(the lowest level). These elements are used to define the hierarchical structure of content, with
<h1>representing the main heading of the page and
This is a Heading 1
This is a Heading 2
This is a Heading 3
This is a Heading 4
This is a Heading 5
This is a Heading 6
<p>element is used to define paragraphs of text. It creates a line break before and after the text enclosed within it, helping to separate content into logical blocks.
This is a paragraph of text.
3. Bold (
<b>) and Italics (
<i>): You can use
<b> for bold text and
<i> for italic text.
<em> carry semantic meaning, indicating the text’s importance or emphasis, while
<i> are purely presentational.
This is important and emphasized text.
<u>) and Strikethrough (
<u>is used for underlining text, while
<del>is used for strikethrough text.
<del>often indicate deleted or outdated content.
<sup>) and Subscript (
<sub>): These elements are used to format text as superscripts and subscripts, respectively. Superscripts are typically used for exponents, while subscripts are used for footnotes or chemical formulas.
x2 + y2 = r2
<code>) and Keyboard Input (
<code>is used to display inline code snippets, while
<kbd>is used to indicate keyboard input. These elements are often used in technical documentation.
To print a message to the console, use
<cite>) and Blockquotes (
<cite>is used to mark the title of a work (e.g., a book or a movie), while
<blockquote>is used for longer quotations, typically indented from the surrounding text.
The Great Gatsby by F. Scott Fitzgerald is a classic novel.
This is a longer quotation that requires a blockquote element.
These are some of the basic HTML text formatting elements and attributes. CSS (Cascading Style Sheets) can be used to further customize the appearance of text, allowing for precise control over fonts, colors, margins, and more.