Register now or log in to join your professional community.
Hi,
Divs should be used to wrap sections of a document, Div tag and Span tag allow the web designer to create the text in various style.
Div tags are block elements means they can hold other HTML elements.
While Span tags cannot hold other HTML elements, they are not block elements, spans should be used to wrap small portions of text, images, etc.
Thanks.
div is a "block" element and span is an "inline" element.
The differntce lies in how the browser treat them to render on your pc.
browser renders two consecutive "block" elements one after another vertically. So you can not use two "block" elements side by side in normal way.
for example your html containts two div as <div>Computer</div><div>Mobile</div>
browser will render above html as
Computer
Mobile
not as Computer Mobile
where as "inline" elements can be displayed side by side in a single line.
for example your html containts two span as <span>Computer</span><span>Mobile</span>
browser will render above html as
Computer Mobile
not as
Computer
Mobile
notice the difference the browser renders two consicutive block elements in two different lines where inline elements are rendered in a single line.
you can make a block element behaves like "inline" element and vice-versa by setting its display property either block, inline, inline-block etc..
Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.