SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    eez
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Is <br /> good practice in XHTML or should I always use paragraphs?

    Hi!

    Let's say I have some text like this:

    January 2005 95:87 PM
    Hi there! My name is Brian.
    Biography: Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there!

    Should I structure the XHTML like this:

    <p>
    January 2005 95:87 PM<br />
    Hi there! My name is Brian.<br />
    Biography: Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there!
    </p>

    OR like this:

    <p>January 2005 95:87 PM</p>
    <p>Hi there! My name is Brian.</p>
    <p>Biography: Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there Hi there hi there!</p>

    And then nullify the margins between the <p />s.


    Thanks for your answers!

  2. #2
    SitePoint Wizard silver trophybronze trophy Nadia P's Avatar
    Join Date
    Oct 2004
    Location
    NSW Australia
    Posts
    3,564
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your second option - use css to style the paragraphs as needed.
    You can create different styles for the paragraph too as needed if you require different spacing for your various page elements.

    #maincontent p {bla bla}
    or
    #footer p {different bla bla}

    Nadia

  3. #3
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are some uses for <br/>, but the are few and far between. Every time you're thinking about using one, take a step back and make sure that it's really necessary. 99% of the time, it won't be.

    There are a few cases I can think of:
    • Postal addresses, where the line breaks have semantic meaning.
    • Poetry or song lyrics, where the line breaks have semantic meaning.
    • Forms, sometimes.
    Birnam wood is come to Dunsinane

  4. #4
    SitePoint Enthusiast ComputerGuru247's Avatar
    Join Date
    Jul 2006
    Location
    Wisconsin
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Autistic summed it up perfectly. Use paragraphs when you can. I use <br /> ocassionaly in my coding, when needed. Try to not overuse it however.
    Bryan

    Breakpoint Designs - Web Design, Logos, and more!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •