Slide 1
Slide 2
Slide 3

span tags in HTML5 (HTML-V22)

No Comments

9. HTML Tags Within Heading Tags
HTML headings (h1 to h6) are used for main headings and subheadings to organize content in an orderly way. Inside these heading tags, you can use other HTML tags to add meaning and make the structure of the content clearer.
9.1. <span> Tag
You can use the <span> tag to apply a style or class inline to a specific part of the text inside a heading. This lets you set a custom style for some of the text in a heading without affecting the rest of the heading text.

Source Code:

Copied!
<!DOCTYPE html>
<html>
<head>
   <title>Using <span> Tag</title>
</head>
<body>
   <h2>This is a <span style="color: red;">Red</span> word.</h2>
</body>
</html>

Result:

Watch the video:


Ebook: https://softkhpc.blogspot.com/2026/11/html-tutorial-beginners.html

back to top