What is the exact advantage of using the <span> tag over the <div> tag?

I know the general difference, but what is the purpose / advantage of using the span tag over the div tag?

t

<p>hello <span>world</span></p>

and

<p>hello <div>world</div></p>

Absolutely no difference in output?

+3
source share
2 answers

You cannot use a div there legally. This is a block element. Span inline.

+3
source

There are different types of elements ( block, inline, table...).

Example for the block elements, h1, p, div, ...

Examples of inline elements: em, block, span, ...

- . (, div), (, p). .

, . .

<p> , , <div> . <span> .

0

Source: https://habr.com/ru/post/1796262/


All Articles