-->
Difference between ""Div" Tag & "Span" Tag

Difference between ""Div" Tag & "Span" Tag

The primary difference between a div and a span is their default behavior. By default, a <div> is a block-level element and a <span> is an inline element. In other words, if you want to adjust a small portion of text and not break it out of the current line, use a <span>. If you need to modify a large division, the height, move an element, or contain other elements, use a <div>.

Example of an HTML <span> tag

Example text that is red text and an example of a span tag.

HTML code

<p>Example text that is <span style="color:red;">red text</span> and an example of a span tag.</p>

Example of an HTML <div> tag

Example of a div tag with a maximum width of 200 pixels and a silver background.

HTML code

<div style="width: 200px; background-color:#E5E4E2;padding:10px;margin-bottom:2em;">
<p>Example of a div tag with a maximum width of 200 pixels and a silver background.</p>
</div>

0 Response to "Difference between ""Div" Tag & "Span" Tag"

Post a Comment

Ads on article

Advertise in articles 1

advertising articles 2

Advertise under the article