Difference Between Div and Span | vs
By BYJU'S Exam Prep
Updated on: September 25th, 2023
In HTML, the use of tags is a basic process to build a page. Tags are rudimentary HTML elements that are used to denote some meaning to the elements. But tags like
Here, we will first discuss what is
Difference Between Div and Span PDF
Table of content
Difference Between Div and Span
Both the general HTML elements span and div serve to group together relevant elements of a web page for various purposes. Although there are a few similarities between the div tag and span tag, there exist a few differences between the div and span tag in HTML. The important differences between the two tags are shown in the table provided below.
Div vs Span | |
Div | Span |
This element of the tag is a block level. | This element or tag is the in-line element. |
These are used to create small divisions. | Used in between lines and doesn’t create a separate section or division. |
Align attribute is accepted by this tag. | Does not accept align attribute. |
They are used to highlight a section in the content. | They are used to wrap a word or bunch of words and not the whole section. |
What is Div?
The
A basic example of a
What is Span?
A span tag or element is also known as an in-line element. This is used in the small sections of the content on the page. They do not start a new line. They are used on texts, images, etc which will be present in the line.
A basic example of a tag is shown below.
style=font-weight: 400;>Civil engineering includes the planning, construction, designing and maintenance of roads, bridges, dams, canals, and buildings.
Key Differences Between Div and Span
The key differences between div and span tags in HTML are given below.
- A div is a block-level element, and a span is an inline element.
- Div tag works best if you affix it to a specific area of a website whereas a span tag is preferable to add CSS to a brief line break on a web page.
- Div tag accepts the attribute align while span tag rejects the attribute align.