Techoceanhub logo

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.

Share:

Categories

Archives

Related Posts

Array Destructuring

Array Destructuring Array destructuring is a powerful syntax introduced in ES6 that allows you to unpack elements from an array

Read More »

Explore our Affiliated partner links

hostgator website plan

Hostgator

Best Website hosting plans & Best for 24/7 support.

hostinger webhosting plan

Hostinger

Reasonable website hosting packages for small business & 24/7 Email support

Elementor pro

Design Worpdress website quickly using Elementor Builder and AI

buy elementor website templates

Buy Elementor Website Template

Buy ready made Elementor Website Template from us & Get Free Elementor pro licence for 1 year .