Both the div and span tags are used to indicate the part of a web page. Divs are block-level elements, whereas spans are inline elements of a web page.
tag is used to show block parts of the webpage whereas tag is used to show inline parts of the webpage.
Example:
<div> My Name is <span> Divya Kumari </span></div>
<span> tag |
<div> tag |
---|---|
Span tag will be used for inline elements and for paragraphs. | Div tags are used for block-level elements. |
Typically, this tag is used to highlight any specific word ( or a small section of a line) on a webpage. | In general, it is used/attached to highlight a section on the webpage. |
In this tag, we use a specific colour code in order to highlight the HTML content. | In this tag, we use borders with height and width with specified colour pixels in order to highlight the HTML content. |
As it does not support the align attribute, the span tag will not appear on a new line. | With support for the align attribute, the div tag will appear on a new line. |