HTML Span Tag

HTML Span Tag

HTML Span Tag

  • The <span> element is an inline element.

  • An inline element does not start on a new line and only takes up as much width as necessary.

    • Example of inline element: <i>,<a>,<b> etc.

  • HTML Span Tag tag does not give any special appearance on web page like <b> tag, <i> tag etc gives. It generally used as a container for HTML elements.

    • Like if we want to change the color of 4 words together then we can use a <span> tag to cover all text in one.

Example:
Some words of <span style="color:blue">this sentence become</span> blue.
Run Code »

Run the code to see the effect.




Difference between the Div and Span Tag

  • Div Tag takes the full width of the screen and Span Tag takes only as much as required to cover the content.

Example:
Some words of <span style="color:blue">this sentence become</span> blue.
Some words of <div style="color:blue">this sentence become</div> blue.
Run Code »

Run the code to see the effect.

Example:
Some words of <span style="background-color:lime">this sentence become</span> blue.
Some words of <div style="background-color:lime">this sentence become</div> blue.
Run Code »

Run the code to see the effect.

Example:
<div style="text-align:right; background-color:lightblue;">
<a href="#">HOME</a> | <a href="#">CONTACT</a> | <a href="#">ABOUT</a>
</div>
Run Code »

Run the code to see the effect.




HTML Span Tag in Hindi

Best Use:360p or more (480p or 720p)
×

Course Menu