html span

The HTML span tag is used to style the content or text inside an element. Let’s know what is span in HTML and how to use the HTML span tag.

<p>This is <span class="myspan">dummy text</span></p>

<h1>This is <span class="myspan">dummy text</span></h1>

<div> This is 
	<span class="myspan">dummy text</span>
</div>

<a> This is <span class="myspan">dummy text</span></a>

<strong>This is <span class="myspan">dummy text</span></strong>

<li>This is <span class="myspan">dummy text</span></li>

.myspan{
	color: red;
	font-weight: 700;
	letter-spacing: 5px;
	font-size: 28px;
	background-color: yellow;
}
.myspan:hover{
	color: blue;
	cursor: pointer;
}

HTML Span Tag

If you want to style more than one word in your paragraph, you can give it with an HTML span tag. In the following example, we have used the span tag several times to style some words.

<p>This is <span class="myspan">dummy text</span>, which we want  <span class="myspan">to use</span> for the  <span class="myspan">dummy purpose</span>

.myspan{
	color: red;
	font-weight: 700;
	letter-spacing: 5px;
	font-size: 28px;
	background-color: yellow;
}
.myspan:hover{
	color: blue;
	cursor: pointer;
}

Browser Support

  • Edge
  • Firefox
  • Internet Explorer
  • Opera
  • Safari
  • Chrome

Frequently Asked Questions

We have answers to some questions that people search on the Internet every day. Let’s know what those questions are and what their answers are.

How do I link CSS to HTML?
To link CSS with html, you can place your file inside the head tag. For example link rel = “stylesheet” href = “mystyle.css”

How do you put a full background image on HTML?
If you want to apply the full background image, then you can apply the image above your body tag. for example Background-image: url (“myimage.jpg”).

What is div in HTML?
In simple language, div is a box inside which you set your elements.

How do you underline in HTML?
With the u tag you can underline your text.

Where do I put CSS in HTML?
There are 3 ways to apply CSS, either you can link your file inside the head tag, or you can add inline CSS, or you can place your CSS on the same page with the style tag.

What is text formatting in HTML?
To make the text appear well, the text is formatted with a few HTML tags.

What is BR tag?
br tag is used to break the line.

What is the HTML code for bold?
You can use b tag and strong tag to bold your text.

What does </ B mean in HTML?
b tag means “bold”.