The Complete WebDeveloper (38 Blogs) Become a Certified Professional

All you Need to Know About Span tag in HTML

Published on Aug 26,2019 10 Views


myMock Interview Service for Real Tech Jobs


myMock Interview Service for Real Tech Jobs

  • Mock interview in latest tech domains i.e JAVA, AI, DEVOPS,etc
  • Get interviewed by leading tech experts
  • Real time assessment report and video recording

Grouping elements to perform a particular action in HTML is a very important task. Span tag in HTML is something that comes into the picture here. Let’s understand what is span tag and how it works in the following order:


What is a span tag in HTML?

In HTML <span> tag is mainly used for grouping of elements and applying styles accordingly to the inline elements. There is a difference between the <span> tag and <div> tag. The <span> tag is used with the inline elements while the <div> tag is used with block-level content.


In a paragraph <span> tag is used to apply a style to a particular group of words. With a given set of font codes. In these, there are three different types to set colors to the web page you have created.


Color Coding for Span Tag

The colors can be directly specified like green, blue. Hex codes – There is a six-digit code which represents the amount of color. Color decimal or percentage values – RGB() property is used to specify the colors. These hexadecimal codes will be preceded by a pound sign or hash sign #. Following is the list of few colors using hexadecimal notations.

ColorHex Code



<!DOCTYPE html>
<title>HTML span tag </title>
<p>This is a paragraph<span style="color:#FF0001;">
<i>This is a paragraph</span></i>
This is a paragraph</p>
<p><span style="color:#8866ff;">
This is another paragraph</span></p>

The output of Code:

span tag in html


As you can see we have successfully implemented the span tag to customize our HTML body. With this, we have come to the end of this article.

Check out our Full Stack Web Developer Masters Program which comes with instructor-led live training and real-life project experience. This training makes you proficient in skills to work with back-end and front-end web technologies. It includes training on Web Development, jQuery, Angular, NodeJS, ExpressJS, and MongoDB.

Got a question for us? Please mention it in the comments section of “Span Tag in HTML” blog and we will get back to you.


Browse Categories

Subscribe to our Newsletter, and get personalized recommendations.