HTML span
Created By: chatGPT
<span>
is an inline HTML element used to apply styles or manipulate parts of a text. It does not inherently change the content but allows you to apply CSS or JavaScript to a specific section without starting a new line. This makes it useful for styling portions of text within larger blocks. Here’s how you can use a <span>
element:<span style="color: blue; font-weight: bold;">This text is blue and bold.</span>
You can also use
<span>
for JavaScript interactions. For example, you might want to highlight specific text when the user hovers over it. Here’s a simple example using CSS and JavaScript:<style>
.highlight {
background-color: yellow;
}
</style>
<span onmouseover="this.classList.add('highlight')" onmouseout="this.classList.remove('highlight')">
Hover over this text to highlight it.
</span>