Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts

    Simple one - <p> and <br /> tags

    Hi Guys,

    Say I have two lines of text and I want to display them with a line in between ie:

    Code:
    <p>This is the first line</p>
    
    <br />
    
    <p>This is the second line</p>
    Is what i'd normally do with the <br /> tag seperating the line. But I understand that's now frowned upon a bit in CSS? So what's the other way of doing it? I know you can set the height of <p> but I don't really want to do that?

    Thanks

    Chris

  • #2
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    This is how I normally do it.

    Frank

    <p>This is the first line<br />
    <br />This is the second line</p>
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #3
    Regular Coder
    Join Date
    Jun 2007
    Posts
    310
    Thanks
    86
    Thanked 3 Times in 3 Posts
    Thanks, but I thought <br /> tags were being phased out?

  • #4
    Senior Coder ahallicks's Avatar
    Join Date
    May 2006
    Location
    Lancaster, UK
    Posts
    1,134
    Thanks
    1
    Thanked 57 Times in 55 Posts
    No <br /> tags! They are not good or semantic. Why don't you just use a bottom margin on that top <p> tag? Create a CSS class for it and just stick a bottom margin however large you want it?
    "write it for FireFox then hack it for IE."
    Quote Originally Posted by Mhtml View Post
    Domains are like women - all the good ones are taken unless you want one from some foreign country.
    Reputation is your friend

    Development & SEO Tools

  • #5
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Quote Originally Posted by ahallicks View Post
    No <br /> tags! They are not good or semantic. Why don't you just use a bottom margin on that top <p> tag? Create a CSS class for it and just stick a bottom margin however large you want it?
    Surely it is not worth css for just a couple of lines of text!
    Semantics is in danger of becoming a "Holy cow."
    You don't need a hammer to crack a walnut.

    I expect that I have put the cat among the pigeons now!

    Frank
    Last edited by effpeetee; 12-21-2007 at 12:12 PM.
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #6
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Good article here about this:<br>
    http://www.robertnyman.com/2007/01/1...r-tag-be-used/
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #7
    Senior Coder effpeetee's Avatar
    Join Date
    Feb 2007
    Location
    Clapham Junction - London SW
    Posts
    4,885
    Thanks
    228
    Thanked 204 Times in 203 Posts
    Quote Originally Posted by _Aerospace_Eng_ View Post
    Very well stated I think. I agree that there should be standards and that they should in general be used, but I don't like rules that bind when it is not necessary.

    It reminds me of one of my fellow airmen in the RAF during the war.
    His favourite line was- Everyone should do as they like, Those that don't, should be compelled to.
    Seriously though, commonsense reigns or should do IMHO.

    Frank
    * Sources (updated: 21.11.2012.
    Using Windows 8 Professional. 64bit with HP Photosmart 5510 printer Very useful site here.

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,639
    Thanks
    0
    Thanked 649 Times in 639 Posts
    If it is a one off then it may be worth making an exception. If it is going to occur more than once on your site then defining a class for it will make it easier for the future.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #9
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    The thing most people forget that p tags are, guess what, paragraphs.

    Although you may be slapping your heads in annoyance, do hear me out. You should not use <p />s for stuff that isn't actually a paragraph. Think back to primary school English.

    There are perfectly valid reasons to have a line break. Poems are formatted with line breaks, and I wouldn't have it any other way. Yet each line is not a paragraph, is it? So <br /> is both semantic and purpuseful. People just misuse it.
    Last edited by Apostropartheid; 12-22-2007 at 02:44 PM.


  •  

    Posting Permissions

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