T E C h O C E A N H U B

Text formatting (bold, italic, underline) in HTML

To apply text formatting such as bold, italic, and underline in HTML, you can use various tags and CSS styles. Here’s how you can achieve each formatting style:

  1. Bold Text: To make text bold, you can use the <b> or <strong> tags. Alternatively, you can use CSS to apply the font-weight: bold; property to the desired element. Here are examples of both methods:

Using <b> tag:

<b>This text will be bold.</b>

Using CSS:

<span style="font-weight: bold;">This text will be bold.</span>
  1. Italic Text: To make text italic, you can use the <i> or <em> tags. Additionally, you can apply the CSS font-style: italic; property to the element. Here are examples of both methods:

Using <i> tag:

<i>This text will be italic.</i>

Using CSS:

<span style="font-style: italic;">This text will be italic.</span>
  1. Underline Text: To underline text, you can use the <u> tag. However, it’s important to note that underlining text is generally discouraged in modern web design due to its association with hyperlinks. Instead, it’s recommended to use CSS to style your text. Here’s an example:

Using CSS:

<span style="text-decoration: underline;">This text will be underlined.</span>

It’s worth mentioning that using CSS styles gives you more control over the appearance and allows you to apply these formatting styles to any HTML element, not just specific tags.

Copyright ©TechOceanhub All Rights Reserved.