Introduction
Today, we will see different ways in which we can mark up text in HTML. Let's learn about some of the informative tags with respect to their representation.
Tags
- There are six different level of headings which help us add beauty to the page (i.e. <h1>, <h2>, <h3>, <h4>, <h5>, <h6>).
- Paragraph <p>, preformatted sections <pre>, link breaks <br />, and addresses tag <address>
- Presentational elements, (<b>, <i>, <u>, <s>, <tt>, <sup>, <sub>, <strike>, <big>, <small> and
<hr />).
- Phrasal elements (i.e. <em>, <strong>, <abbr>, <acronym>, <dfn>, <blockquote>, <q>, <cite>, <code>, <kbd>, <var>, <samp> and <address>).
- Ordered and unordered lists, using <ol> and <ul>. Adding elements to the list <li>, and definition of the list using <dl>, <dt> and <dd>.
- Editing elements, <ins> and <del>
- Grouping elements, <div> and <span>
All the tags listed above help learn how to better use HTML. Now, let's start to learn the basic text formatting:
Basic Text Formatting
The following elements are considered to be basic text formatting elements:
<h1>, <h2>, <h3>, <h4>, <h5>, <h6> along with <p>, <br />, <pre>.
- <html>
- <head>
- <title> Basic Text Formatting </title>
- </head>
- <body>
- <h1> Getting to know HTML Basic Formatting Tags</h1>
- <p> The blog you are reading is letting you learn the basic text formatting tags </p>
- <p> This paragraph shows how multiple spaces between words are treated as a single space. This is known as white space collapsing, and the big spaces between some of the words will not appearing in the browser. </p>
- </body>
- </html>
Use of <pre> tag
The <pre> tag will make the text between, <pre> </pre>, shown in browser as it is.
- <html>
- <head>
- <title> Basic Text Formatting </title>
- </head>
- <body>
- <h1> Getting to know HTML Basic Formatting Tags</h1>
- <p> The blog you are reading is letting you learn the basic text formatting tags </p>
- <h2> Whitespace and Flow </h2>
- <pre> This paragraph shows how multiple spaces between words are treated as a single space. This is known as white space collapsing, and the big spaces between some of the words will be appearing in the browser. </pre>
- </body>
- </html>
Now, let's learn about the alignment. The align attribute <align> help us align the text. Headings left, right or center.
Example:
- <html>
- <head>
- <title> Learning about aligning the text</title>
- </head>
- <body>
- <h2 align = left> Left Aligned Heading </h2>
- <p align = left> the paragraph with left alignment of text </p>
- <h2 align = center> Centre Aligned Heading </h2>
- <p align = center> the paragraph with center aligned </p>
- <h2 align = right> the heading is right aligned</h2>
- <p align = right> the paragraph is right aligned </p>
- </body>
- </html>
In the next blog, we will be discussing line breaks and some further elements.