How to define a part of the text in an alternate voice or mood using HTML5?


In this article, we will discuss how to define a part of the text in an alternate voice or mood using HTML5. HTML5 provides a range of tags that allow web developers to structure the content of a web page in a more meaningful way. One important aspect of this is being able to emphasize certain words or phrases, like making them italic or bold. This helps the content look better and be easier to read for users.

Approaches

We have two different approaches to defining a part of the text in an alternate voice or mood using HTML5 including the following −

  • Using the “<i> element”

  • Using the “<em> element”

Let us look at each step in detail.

Approach: Using the "<i> method"

The first approach is to define a part of the text in an alternate voice or mood using HTML5 as “<i>”. The <i> tag is used to define a part of the text in an alternate voice or mood. By default, it renders the text in italic font style. It is commonly used to emphasize text.

Example

Following is an example to define a part of the text in an alternate voice or mood using HTML5 using “<i>”.

<!DOCTYPE html>
<html>
<head>
   <title>Alternate Voice Example</title>
   <style>
      h1 {
         color: blue;
      }
      h2 {
         color: green;
      }
      .alternate {
         color: red;
      }
   </style>
</head>
<body>
   <h1>Tutorials Point Articles</h1>
   <h2>Different Web Development Languages</h2>
   <ul>
      <i class="alternate">Hypertext markup language (HTML)</i>
      <li>Cascading style sheets (CSS)</li>
      <li>JavaScript</li>
      <li>PHP</li>
      <li>Node.js</li>
   </ul>
</body>
</html>

Approach: Using the "<em> method"

The first approach is to define a part of the text in an alternate voice or mood using HTML5 as “<em>”. The <em> tag is used to emphasize text and by default, it is displayed in italic font. It is similar to the <i> tag, but it has a semantic meaning of indicating emphasis rather than just alternate voice or mood.

Example

Following is an example to define a part of the text in an alternate voice or mood using HTML5 using “<em>”.

<!DOCTYPE html>
<html>
<head>
   <title>Example using the <em> tag</title>
   <style>
      h1 {
         color: green;
      }
      h2 {
         color: red;
      }
      .emphasis {
         color: blue;
         font-style: italic;
      }
   </style>
</head>
<body>
   <h1>Tutorials Point Articles</h1>
   <h2>Different Programming Languages</h2>
   <ul>
      <li><span class="emphasis">Hypertext markup language (HTML)</span></li>
      <li>Cascading style sheets (CSS)</li>
      <li>PHP</li>
      <li>JavaScript</li>
      <li>Node.js</li>
   </ul>
</body>
</html>

Conclusion

In this article, we examined two different approaches to defining a part of the text in an alternate voice or mood using HTML5. Here, we are using two different approaches “<i>” and the “<em>”. The "<i>" tag is used for marking up text in an alternate voice or mood, while the "<em>" tag is used for emphasizing text. When you are deciding whether to use "<i>" or "<em>" to format text on a web page, you should consider what message you want to convey with the text. Which one you choose depends on the needs of your project and how you want to structure and organize your content.

Updated on: 19-Jul-2023

61 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements