Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Basics Images, Text and Links Add Meaning to Words with Text Level Elements

Yunsik Ohm
Yunsik Ohm
887 Points

What is the difference between <span> and <a>?

I'd like to know the difference between <span> and <a>. The functions of those command look similar to me.

grant Mitchell
grant Mitchell
6,919 Points

huge difference bro. a is to link span is to change a small portion of text or something, or to select small pieces of text. I suck at explaining but thats all i got for ya. The thing is tags kind of don't really mean anything, i mean some do. but overall its the css and javascript that really give it meaning.

3 Answers

Brandon Spangler
Brandon Spangler
8,756 Points

An <a> tag is used to define hyper-links. The <span> tag is an in-line element with no semantic meaning, usually meant to style sections of a page.

grant Mitchell
grant Mitchell
6,919 Points

yeah brandon can explain it better. bur just keep using it and youll make the connections.

Another thing to add is an <a> tag is a self closing tag and a <span> needs a closing tag </span> in your html write up. Also: <a> tags are most commonly used in creating navigational markup in your html, they can be used in other places as well on your html too. <span></span tags are commonly used when you want to style a specific letter, word, or section of text on a page.

marcos rodriguez
marcos rodriguez
1,214 Points

Not sure if you figured it out, but easiest way I thought of was that <span> is going to make it really easy when you style with CSS. So example: <span class="sentence"> right, then when you go into CSS you can easily edit it. Example: (in CSS) .sentence {color="blue" font-size="14"} Other then that no major need for it in html.

And <a> is for linking pages together for the most part, example: <a href="#">, or <a href="https://teamtreehouse.com/vr">

Hope that helped!! Good luck!