-3

there are two tags in html , one is div and another one is span.. now I wish to know the difference between these two tags according to their functions and roles...

I tried both the tag but I didn't found any unique difference between both, so I am expecting to get the detailed answer .

1 Answers1

-2

Div element defines a section in a document (block-level).

Span elememt also defines a section in a document (inline).

So what's the difference between block-level and inline.

There are two types of elements in html.

Block-Level Elements. Inline Elements. Block-Level Element always starts on a new line and takes up the full width as possible. Inline Elements doesn't starts on a new line and takes up as much width as necessary. You cannot put a block-level elememt into an inline element.

Div is a block-level element and Span is an inline element.

  • 1
    That's **very** out of date. HTML 5 (published 14 years ago!) did away with the Block and Inline categorisation of elements. – Quentin Dec 10 '22 at 16:34
  • @Quentin block and inline is the first words of the dupe you posted. What are you referring to? [The HTML element is a generic inline container for phrasing content, which does not inherently represent anything](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span) ------- [block-elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements) – mplungjan Dec 10 '22 at 16:39
  • Answers on the duplicate are, sadly, rather dated … but that doesn't stop the question being a duplicate. MDN also needs a refresh. The [spec is here](https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-span-element). It describes span as flow, phrasing, and palpable, but not inline. – Quentin Dec 10 '22 at 16:42