+ 2

Please someone should explain the <span> attribute please

6th May 2020, 9:50 AM
David Igbineweka
David Igbineweka - avatar
3 ответов
+ 13
Span is not an attribute it's an inline element similar to div element. Div is a block level container where as span is a inline container. Block level: Block level elements start with a new line. Ex: Div, ol, ul, li, h1-h6, p etc Inline: These elements don't start with a new line. Ex: img, a, b, i etc Using span element we can style inline tags using style attribute. Ex: <h1> <span style = color:"blue">Sololearn</span> is awesome! </h1> Output: Sololearn(in blue shade) is awesome!
6th May 2020, 10:03 AM
Viren Varma
Viren Varma - avatar
+ 2
David Robby Hey, it is just as simple as a <p> tag. Although span is an inline element whereas p is block. Inline : An inline element never starts with a line break. What do I mean by this? Consider the following example : Code : <span>Hi there Robby.</span> <span>How are you?</span> Output: Hi there Robby.How are you? As you can see, the output is just in a line, although we have written two span tags in two lines. However, again Block : Code : <p>Hi there Robby.</p> <p>How are you?</p> Output : Hi there Robby. How are you? See, we didn’t write p in two lines, but still we are getting the result in two lines. Now span is just an inline element. What's the purpose of it? Well, most often, you can use it to style a specific text. Also, it sometimes is used to make simple shapes and design :))
6th May 2020, 10:00 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
Thanks
6th May 2020, 10:04 AM
David Igbineweka
David Igbineweka - avatar