Difference Between Two HTML Tags That Are Commonly Used

Asked By 60 points N/A Posted on -
qa-featured

In HTML, there are two tags: div and span. What do each of these tags do? Are they the same? If no, then, what is the difference between these two HTML tags?

SHARE
Answered By 20 points N/A #186849

Difference Between Two HTML Tags That Are Commonly Used

qa-featured

The div tag in HTML is used to group contents in the page together. The span tag too is used to group a number of contents of the page together. These two tags are not the same. They both have some differences. The div tag is a block-line tag and it is used to group large amounts of code together, whereas the span tag is an in-line tag and it is used to group small amounts of code as one. 

Answered By 567070 points N/A #186850

Difference Between Two HTML Tags That Are Commonly Used

qa-featured

The HTML div tag, <div></div>, identifies a section or division in an HTML document or file and is used to classify block-elements to format them with CSS. The div tag is used in pair and should always have its closing tag, </div>. It is supported in all major web browsers: Google Chrome, Windows Internet Explorer or Edge, Mozilla Firefox, Safari, and Opera.

It is very frequently used together with CSS to layout a web page. Web browsers constantly put a line break before and after the div tag. But this can be modified using Cascading Style Sheet or CSS. Take note, the align attribute used in div tag is not supported in HTML5. The HTML span tag, <span></span>, is used to classify inline-elements in an HTML document or file.

It offers no visual change by itself. It is supported in all major web browsers: Google Chrome, Windows Internet Explorer or Edge, Mozilla Firefox, Safari, and Opera. It also provides a method to add a hook to a portion of a text or a portion of a document. When you hook a text with the span tag, you can style it using CSS or manipulate it using JavaScript.

The HTML span tag is used in pair and should always have its closing tag, </span>.

Login/Register to Answer

Related Questions