Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Difference b/w Div and Span Tags

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 194
    Comment on it

    Hello readers, Toady in my blog I will discuss upon the difference b/w Div and Span tag in HTML.

     

    For every beginner it is very confusing where to use which tag either Div or Span.

     

    The <span> and <div> tags are very useful when used in Cascading Style Sheets.

     

    What is Div Tag ?

    • The Div tag divides the tag into larger sections.

     

    • It also help us to define the style of whole section of HTML.

     

    • It help us to give the ability to name certain sections of our document in HTML.

     

    • It acts as a paragraph end/beginning, if we have a paragraph within a <div> but we can not have a <div> inside a paragraph.

     

    • The primary attributes of the <div> tag are :-

    style, class and id .
    Eg:-

    <div id=scissor>
    
    <p> This is <strong class=paper>crazy</strong></p>
    
    </div>

     

    What is Span Tag ?

    • It has similar properties as div tag.

     

    • It changes the style of the text placed within it.

    Eg :-

    <div id=scissor>
    
    <p>This is <span class=paper>crazy</span></p>
    
    </div>


     

    The Difference b/w the both Tag :-

    • The main difference b/w the both tag is that the <span> tag does not do the formatting of its own while the div tag includes a paragraph break as it breaks the page into larger sections.

     

    • The Second difference among the both tag is a span element is in-line and act as a child of another block element while a div tag is a block element that means it has its own separate line.

     

    • Div is used as a placeholder in a web page and can apply same style to everything in the placeholder while span tag is used to style specific text only when we have text inside the other text and we want to change the font/color/size of them.

    Conclusion :-

    Hence, reading the above explanation any user can distinguish b/w the Div and Span Tag.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: