Articles → HTML → Span Tag In HTML
Span Tag In HTML
What Is An Inline Element?
What Is A Span Tag?
- Styling the inline element (using a style sheet)
- Identify the inline element (using a script)
Syntax
Example
- Show the charging percentage
- Show the label as red if the battery is not 100% charged and green color if the battery is 100% charged.
- Update the battery status
- Change the color
<!DOCTYPE html>
<html lang="en"
xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>Span Demo</title>
<style>
.HundredPercentCharged {
color: blue;
}
.LessThanTenPercentCharged {
color: red;
}
</style>
</head>
<body>
Your battery is <span class="HundredPercentCharged">100% charged</span> <br />
Your battery is <span class="LessThanTenPercentCharged">10% charged</span>
</body>
</html>
Try It
Browser Support
Internet Explorer | Firefox | Chrome | Safari | Opera | Edge |
---|
Yes | Yes | Yes | Yes | Yes | Yes |