Skip to content
Azril Hakim

Text Fomating

In HTML, you can format text to make your web content more appealing and structured. This section covers various text formatting techniques and elements you can use.

Adding Text to Your Page

Text is fundamental in web development. To add text to your HTML page, you can simply type it within the <body> element.

<!DOCTYPE html>
    <title>My HTML Page</title>
    <p>This is some text on my webpage.</p>

Headings and Paragraphs

Headings and paragraphs are essential for structuring your content.

<h1> to <h6> elements are used for headings, with <h1> being the highest level of importance and <h6> the lowest. <p> elements are used for paragraphs. Example:

<h1>Main Heading</h1>
<p>This is a paragraph.</p>
<p>Another paragraph here.</p>

Line Breaks <br>

Sometimes, you may want to force a line break within text. You can use the <br> element for this purpose.


<p>This is some text.<br>And this is on a new line.</p>

Text Styling: <strong>, <em>, <u>, <s>

HTML provides elements to apply various text styles:

<strong> for strong emphasis (typically displayed as bold). <em> for emphasizing text (typically displayed as italic). <u> for underlining text. <s> for strikethrough text. Example:

<p>This is <strong>important</strong> information.</p>
<p><em>Emphasize</em> this text.</p>
<p><u>Underline</u> this.</p>
<p><s>Strikethrough</s> this.</p>

Lists: Ordered and Unordered Lists help organize content. HTML supports both ordered and unordered lists.

Ordered lists <ol> use numbers or letters to list items. Unordered lists <ul> use bullets to list items. Example:

<h3>Ordered List:</h3>
    <li>Item 1</li>
    <li>Item 2</li>
    <li>Item 3</li>

<h3>Unordered List:</h3>
    <li>First item</li>
    <li>Second item</li>
    <li>Third item</li>

These are some of the basic text formatting techniques in HTML. You can combine these elements creatively to format your content effectively.