Activity Forums Salesforce® Discussions Difference between 'div' and 'span' tags in Salesforce

  • Satyakam

    Member
    January 5, 2017 at 7:21 am

    Hi Kumar,

    Span-

    While a span allows you to separate things from the other elements around them on a page or within a document, it does not cause a line break. This is why it is perfect for in-line styling, like coloring a single word in a sentence to draw more attention to it.

    Div-

    But a div, by default, creates a line break because it is used to make separate containers or boxes within a page or document, hence the name division. So the proper way to use a div is as a containing element, rather than an inline styling element.

    Thanks

  • shariq

    Member
    September 19, 2018 at 11:55 am

    Hi,

    The difference between span and div is that a span element is in-line and usually used for a small chunk of HTML inside a line (such as inside a paragraph) whereas a div (division) element is block-line (which is basically equivalent to having a line-break before and after it) and used to group larger chunks of code.

    Thanks

  • Avnish Yadav

    Member
    September 19, 2018 at 12:29 pm

    Hello,

    Div and span tag is an HTML tag and we use div tag for the division or we say a new line and span tag for in-line content.

    Thanks.

  • Parul

    Member
    September 19, 2018 at 12:44 pm

    Adding some point:

    The div is a block level, meaning it's on its own separate line.

    It is better referred for a block of content having different nested elements,

    span is inline, so it's a child of another block level element.

    spen is nothing but an empty element,

     

    Thanks

Log In to reply.

Popular Salesforce Blogs