Of the manyHTMLelements you’ll encounter on your journey to front-end mastery, span is one you’ll see very often. But, unlike other elements, thetag doesn’t create a specific type of page element on its own. At first, this might be confusing — what’s an element likeactually used for?

一个s it turns out, a lot. Span elements give designers and developers tight control over the styling and formatting of their web pages and content. If you want to know how web pages are built, you should get comfortable withtags and their purpose.

In this guide, we’ll introduce you to the span element in HTML. We’ll show you how they’re written, what they’re meant for (and what they’re not), and give some examples of spans in action. Finally, we’ll clarify the difference between span and a similar element, the div. Let’s get started.

Download Now: Free Intro Guide to HTML & CSS

一个span tag is written with an opening and a closing tag, like so:


Content goes here

The span element is called “generic” because the name of the tag itself doesn’t tell us anything about the contents of the element. In other words, “span” doesn’t mean anything to us. The opposite of a generic HTML element is asemantic HTML element, one whose name describes its purpose (e.g.,

for paragraph,