The ‘div’ and the ‘span’ tags are quiet frequently used tags in HTML. The proper understanding of these tags are very much important for a web HTML developer.This article is shows what are the characteristics of both these tags. Understanding the difference between both tags will help to use them in appropriate place.
div Tag:
Following are the characteristics:
- As the name indicates, the div tag defines a ‘division’ in a web page.
- div is a block-element; its default display value is “block”.
- div tag is commonly used while creating Css based layouts in html.
- by default, a line-break is placed before and after this element.
span tag:
Following are the characteristics:
- span tag makes no visual difference in the page, unless customised with style attribute.
- span is an in-line element.
- span is commonly used to stylize texts. The in-line feature makes it easy to use custom styles without changing the layout.
- No line-breaks by default, but this can be achieved if we change its in-line nature by specifying in the style attribute to ‘display:block;’