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:
Headings (
to): HTML offers six levels of headings, ranging from(the highest level) to(the lowest level). These elements are used to define the hierarchical structure of content, withrepresenting the main heading of the page andrepresenting subheadings.
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
): The 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 ( or ) and Italics ( or ): You can use or for bold text and or for italic text. and carry semantic meaning, indicating the text’s importance or emphasis, while and are purely presentational.
This is important and emphasized text.
) and Strikethrough ( or ): is used for underlining text, while or is used for strikethrough text. and often indicate deleted or outdated content.
Underlined and strikethrough text.
) and Subscript (): 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
) and Keyboard Input (): is used to display inline code snippets, while is used to indicate keyboard input. These elements are often used in technical documentation.
To print a message to the console, use console.log('Hello, World!');
) and Blockquotes (): is used to mark the title of a work (e.g., a book or a movie), while 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.
Conclusion
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.
