Skip to content

Try our new Crash Courses!

Become a member using the button below to hide this banner and gain access to our new Crash Courses.

span element – HTML

Demo

Summary

To style a section of text inside of another element, use the span element to wrap the text and add a class or id attribute to it, like this:

<p>The span element is used to <span class="my-class">style text inside</span> of another element.</p>

Exercises

First, recreate the HTML code in the embedded CodePen demo.
Then recreate the CSS code in the embedded CodePen demo.

References

span element on MDN

Lesson tags: Open Lesson
Back to: CSS Reference > CSS HTML Elements