You have already seen some text elements. Text elements are used to contain text content. You saw the largest title element <h1>. There are actually 6 levels of titles, 1 to 6. Header elements represent six levels of section headings. <h1> is the highest section level and <h6> is the lowest.
language=>HTML
<h1>h1. heading</h1>
<h2>h2. heading</h2>
<h3>h3. heading</h3>
<h4>h4. heading</h4>
<h5>h5. heading</h5>
<h6>h6. heading</h6>
For normal text, it's best to enclose it in the paragraph tag <p></p>.
language=>HTML
<p>This is a paragraph about something interesting.</p>
Emphasize and Italicize
Remember the emphasize <em></em> tag? There is actually another tag that italicizes text, it's the <i> tag and carries a different semantic value. The <i> element represents a range of text that is set off from the normal text for some reason, for example, technical terms, foreign language phrases, or fictional character thoughts. It is typically displayed in italic type.
<em> and <i> carry different semantic meanings. Recall semantic values are used by screen readers and web crawlers to better understand the context of your content. For more about semantic values of HTML elements, please refer back to chapter 4.1. You can see the detail meanings of each element on https://developer.mozilla.org/en-US/docs/Web/HTML/Element.
language=>HTML
<!-- emphasis -->
<p>I think you <em>should</em> do it.</p>
<!-- foreign language phrases -->
<p>that old <i>cliché</i> 'a woman's place is in the home'</p>
Strong and Bold
The <strong> tag we used earlier also has a sibling. The <b> element represents a span of text stylistically different from normal text, without conveying any special importance or relevance, and that is typically rendered in boldface.
<strong> and <b> carry different semantic meanings. Recall semantic values are used by screen readers and web crawlers to better understand the context of your content. For more about semantic values of HTML elements, please refer back to chapter 4.1. You can see the detail meanings of each element on https://developer.mozilla.org/en-US/docs/Web/HTML/Element.
language=>HTML
<!-- Strong -->
<p>You <strong>must</strong> come to the dinner.</p>
<!-- foreign language phrases -->
<p>This restaurant closes on <b>Monday</b> and <b>Tuesday</b></p>
<p>You <strong>must</strong> come to the dinner.</p>
<p>This restaurant closes on <b>Monday</b> and <b>Tuesday</b></p>
<style>
p {
background: skyblue;
}
body {
padding: 30px;
}
Remember to always close your inner tags first before closing outer tags. This is an invalid code.
language=>HTML
<!--Invalid:--> <p><strong>I love </p>HTML</strong>
Smaller Text
Another useful element is <small>. This element represents side-comments and small print, including copyright and legal text, independent of its styled presentation. It makes the content smaller in comparison to its surrounding text.
language=>HTML
<p>Check out this Offer! <small>Terms and conditions apply.</small></p>
Line Breaks
One more element I want to tell you about. The <br> element lets you create a line break in your paragraph. It is useful for writing a poem or an address, where the division of lines is significant.
language=>HTML
<!-- writing content in a new line does not render it so -->
<p>
This is the first line,
this is the second line.
</p>
<!-- You need to use the <br> tag -->
<p>This is the first line,<br>this is the second line.</p>
Exercise - Only do the following exercises