PDA

View Full Version : What is the css version of <br /> ?



njfail
Dec 31st, 2010, 05:48 PM
I've been working through my code as I add more and more to my site; and I'm trying to keep all stylings inside the css sheets and out of the html.

So my question is, how do I end a line of text and start it on a new line with css? (basically, so I can get rid of all the <br /> lines I have in my html).

Also, on a side note, should I remove the <p> tags from my html and format the text inside the containing div?

teedoff
Dec 31st, 2010, 06:02 PM
<p> tags WILL start new lines of text..lol You can use the <p> tags instead of the <br /> tags. The <p> will add a bit of spacing between each paragraph, but that can be taken out with CSS.

If you have two paragraphs, one on top of the other, and you want to add more space between them using external stylesheets, then add some margins on the <p> tags. To add margins to a CERTAIN <p> tag, you will need to give that <p> an ID:

<p id="firstParagraph">All your text goes here</p>

Then style the id of .firstParagraph with some margin.

Not sure why you would want to remove paragraph tags if after all you are displaying paragraphs of text. List tags are for displaying lists, heading tags are for displaying headings, and paragraph tags are for displaying good ole fashoined paragraphs of text.

Major Payne
Jan 1st, 2011, 08:20 PM
Semantically, if the break tag was starting a new paragraph, you would be better off using the "p" tags. You can then adjust the paragraph spacing using margins in your CSS. Example:


p {
margin: 1% 0;
}

Of course, more CSS styling could be done for the "p" tags according to your needs.

VIPStephan
Jan 1st, 2011, 09:51 PM
<p> tags WILL start new lines of text..lol You can use the <p> tags instead of the <br /> tags. The <p> will add a bit of spacing between each paragraph, but that can be taken out with CSS.


Just for the records: The <p> element should only be used to mark up entire paragraphs of text, not to just insert line breaks or whatever. A single line of text is usually not a paragraph so semantically a paragraph element is wrong (exceptions prove the rule).