What does <span> tag help you do? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What does <span> tag help you do?

Question regarding a tag

23rd Jun 2019, 5:40 AM
Surbhi Goel
5 Answers
+ 6
You may like to style some texts on a line, not the whole line or paragraph. Span is an inline element which let's you do something like this. HTML : Hello <span>World</span> !! CSS : span {color:red;} Color of "World" will be red. Not the whole line.
23rd Jun 2019, 5:53 AM
Ayan Fox
Ayan Fox - avatar
+ 3
Div VS Span: Span doesn't force a new line. Example: ⚡️Span⚡️: <p> Long time ago <span> Apples </span> used to be nice. </p> Result is: Long time ago Apples used to be nice. ⚡️Div⚡️: <p> Long time ago <div> Apples </div> used to be nice.</p> result is: Long time ago Apples used to be nice. The span didn't do anything to the text. But the div started a new line after the word 'ago'. So you can use Span for styling a specific text.... It might have other usages, but - that's all i know. ill make u a code Div vs Span, if u need too
23rd Jun 2019, 5:56 AM
Ginfio
Ginfio - avatar
+ 1
So you can do inline styles.
23rd Jun 2019, 5:51 AM
Jackson O’Donnell
+ 1
Thank you Jackson. Does it not help me put a heading? As a background additional information to my question, I'm asking this in HTML.
23rd Jun 2019, 5:53 AM
Surbhi Goel
+ 1
Thanks a lot, Ayan, Ginfio! :)
23rd Jun 2019, 5:59 AM
Surbhi Goel