What is a <span> tag?

Experience Level: Junior
Tags: HTML

Answer

  • The <span> tag is used as a container to group parts of text
  • The <span> is similar to <div> tag, but it is in-line element, which means it doesn't start on the new line when rendered in the browser
  • The <span> doesn't change a look of a text in any way, unless a CSS style is applied to it
  • The attributes that are often used in the <span> tag are class="..." and style="...". We don't recommend using the latter as the in-line styles are generally considered a bad practice.
Example
<p>
	This is <span>a text with no visual change</span>,
	this is <span style="color: red;">a red text</span>,
	this is <span class="my-class">a text styled using CSS class</span>.
</p>	

Comments

No Comments Yet.
Be the first to tell us what you think.
HTML for beginners
HTML for beginners

Are you learning HTML ? Try our test we designed to help you progress faster.

Test yourself

Chat

Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.

Comments

Anonymous
Καλησπέρα.
Anonymous
the infinteis -3/15 so 1triition / infinet
Anonymous
e
Anonymous
<a href="https://inspirum.pl "
Anonymous
[url]https://inspirum.pl[/url]
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e
LaceJaguar65
e