...

View Full Version : Simple one - <p> and <br /> tags



stfc_boy
12-21-2007, 10:23 AM
Hi Guys,

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



<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

effpeetee
12-21-2007, 10:35 AM
This is how I normally do it.

Frank

<p>This is the first line<br />
<br />This is the second line</p>

stfc_boy
12-21-2007, 10:45 AM
Thanks, but I thought <br /> tags were being phased out?

ahallicks
12-21-2007, 10:56 AM
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?

effpeetee
12-21-2007, 11:42 AM
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

_Aerospace_Eng_
12-21-2007, 02:45 PM
Good article here about this:<br>
http://www.robertnyman.com/2007/01/17/should-the-br-tag-be-used/

effpeetee
12-21-2007, 05:19 PM
Good article here about this:<br>
http://www.robertnyman.com/2007/01/17/should-the-br-tag-be-used/
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

felgall
12-21-2007, 08:08 PM
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.

Apostropartheid
12-21-2007, 08:41 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum