HTML Elements: <span>

By: Dusty Arlia
Published on Tuesday, July 30, 2013, 06:31 AM
Last Updated on Wednesday, July 15, 2015 at 2:37 PM
Total Updates: 3

The HTML <span> element is used to select text inside of a paragraph. The <span> tag does not visually change the appearance of the encapsulated text by itself. You can style the enclosed text with CSS, or manipulate it with JavaScript. Here is an example:

<p>Let me tell you something <span class="emph">REALLY</span> important.</p>

You can add a class attribute to the span element. This allows you to select the span element using the class name. Once the class attribute is assigned a value, you can use it as a CSS selector. In this case the class attribute is set to "emph". Here's how you would use this class in a CSS rule:

.emph {
font-size:larger;
font-color:red;
font-weight:bolder;
}

Comments:

Ad: