In this blog, we will see the basic text formatting elements like center Element and <pre> Element etc.
HTML Formatting Elements
Formatting elements were designed to display special types of text:
- <center> – Centring Content
- <pre>- Text in same format
- <b> – Bold text
- <i> – Italic text
- <u> – Important text
- <sub> – Subscript text
- <sup> – Superscript text
- <small> – Smaller text
The Html <center> Element:
The Html <center> element is used for content in the center of the page or any table cell.
Example1
<!DOCTYPE html> <html> <body> <p>This is my first paragraph.</p> <center> <p>This paragraph is in the center.</p> </center> </body> </html>
Output
This is my first paragraph.
This paragraph is in the center.
The Html<pre> Element:
To display the text in the same format as to how it is written in the HTML file, use the preformatted tag (<pre>).
Putting any content between the starting <pre> tag and the closing </pre> tag will preserve the formatting of the source document.
Example2
<!DOCTYPE html> <html> <body> <h1>The <pre> Element</h1> <pre> Content in a pre element is shown in a fixed-width font, and it preserves both text spaces, tabs and line breaks </pre> </body> </html>
Output
Content in a pre element is shown in a fixed-width font, and it preserves both text spaces, tabs and line breaks