Grow your CSS skills. Land your dream job.

correct use of <br> ?

  • # November 21, 2008 at 4:02 am

    Which code is semantically correct ?

    This

    Code:

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

    Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.Lorem ipsum dolor sit amet, consectetuer adipiscing elit

    or this

    Code:

    Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

    Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.Lorem ipsum dolor sit amet, consectetuer adipiscing elit

    box
    # November 21, 2008 at 5:27 am

    The first is correct. p=paragraph so a new paragraph should begin with a <p> tag. There aren’t many reasons to ever use <br> – one might be for representing poetry, where each line is not a paragraph but demands it’s own space.

    # November 21, 2008 at 5:37 am

    OK . understand THX BOX

    # November 21, 2008 at 6:48 am

    so BR has no use in our mark-up except poems and other same things ?

    # November 21, 2008 at 12:26 pm
    "jitendra" wrote:
    so BR has no use in our mark-up except poems and other same things ?

    when you want to break the line……

    I use it a lot I must admit, mind you p /p or br br that is the question???

    I find it easier to use br br, but I am not a purist, i just find it easier

    # November 25, 2008 at 10:40 am

    something like

    p { padding: 10px 0 0 0 }

    will work and is even easier then <br />

    or put it on the bottom padding, however works best for you or the project.

    :o)

    # November 25, 2008 at 11:01 pm

    I only ever use it for something like this:

    Code:

    Contact Info:
    First Last
    555-555-5555
    name@company.com

    If you’re starting a new paragraph, use the <p> tag.

    # November 26, 2008 at 1:27 am

    is this better way to do this ?

    <ul>
    <li>Contact Info:</li>
    <li> First Last</li>
    <li> 555-555-5555</li>
    <li> name@company.com
    </ul>

    # November 26, 2008 at 1:39 am

    Yes, but that requires extra styling, something that I’m usually too lazy to set up.

    # November 26, 2008 at 1:49 am

    but this is a listing not a paragraph so i think use of <p> and <br> is not a semantic use

    # November 26, 2008 at 2:58 am

    I would have to disagree with you there. Perhaps it’s not the best example. What if I simply want to break a line?

    <p>This is the first part<br /> I want this part to be dropped down below it.</p>

    I would say that is perfectly acceptable and, if I’m not mistaken, exactly what the <br> is there for.

    # November 26, 2008 at 3:11 am

    <address> tag is much more sematic than ul li as i think. u r showing Contact info not a content text so i would not use <p> and <br> to show contact info atleast.

    box
    # November 26, 2008 at 7:51 am
    "TheDoc" wrote:
    I only ever use it for something like this:

    Code:

    Contact Info:
    First Last
    555-555-5555
    name@company.com

    If you’re starting a new paragraph, use the <p> tag.

    This would be an ideal situation to use Microformats. In it’s current state the information displayed is meaningless to other computers, therefore you cannot share that information easily nor can you have any impact in terms of SEO. To mark up your content semantically, using appropriate, meaningful tags with their intended function (as laid out at the w3c), then your sites will be searchable and shareable – thus making them achieve higher positions in search engine results and allow greater networking potential. The <br> tag is pretty meaningless in these terms and although not officially deprecated yet, it doesn’t add any meaningful value to your markup. Avoid it’s use unless you feel you have a valid semantic reason to do so.

    box
    # November 26, 2008 at 7:54 am
    "jitendra" wrote:
    <address> tag is much more sematic than ul li as i think. u r showing Contact info not a content text so i would not use <p> and <br> to show contact info atleast.

    The address tag was not intended to be used for street addresses. Rather the address relating to the document itself. It might seem strange but using the <address> tag for your home address is not semantic in HTML terms.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".