• 0

<br /><br /> Versus <p></p>


Question

For a long time ... well, forever I've been using <br><br>, or <br /><br /> recently, to divide paragraphs. I've always found WYSIWYG editors' tendancy to put <p> around things annoying. However, a post here a while back got me thinking. I don't remember the post exactly, but it was subtly knocking the people like me who use <br /><br />.

Why?

Is there any actual advantage of one over the other? Is the a correct way of doing this?

Link to comment
Share on other sites

Recommended Posts

  • 0
<hr> is deprecated (no longer valid)...It's like the worst tag ever to conceived.

so what replaced <hr> then? how else do i do horizonal rules? i like how IE handles them. i can color them and stuff.

Mozilla/Netscape leaves them at system default color.

what am i supposed to use to make a line or seperate blocks of text i want seperate?

Link to comment
Share on other sites

  • 0
so how is <hr> escaped? does <hr /> work/exist too now?

<hr> is deprecated (no longer valid)...It's like the worst tag ever to conceived.

Yes, but <hr /> is perfectly valid. Many pages that have their stylesheets hidden from non CSS-compliant browsers will use, normally hidden in the stylesheet, <hr /> to divide content for these browsers. It is deprecated in favor of using styles to create the same effect, however they are not invalid (at least not in XHTML 1). Indeed when that tag was created back in the day it was done so for a reason, to help visually seperate content in a time when stylesheets weren't what they are now.

To anyone wanting to really learn more about this and other aspects of web standards, I would recommend visiting W3C. I've seen too many wrong statements in this thread for anyone to have learned the right way to do things.

To xGarret, the point is that your code will NOT work in future browsers, plain and simple. Why write bad code when it's just as easy to write good code? It can still be for the fun of it, just take some pride in your efforts. In addition, you don't have to use XHTML, you can code in HTML and still have compliant code, and it doesn't bar you from using CSS either.

A little about the <p> and <br /> tags. The paragraph tag <p> is just that, it's wholly self explanatory. It encapsulates a series of text so that it is easily recognised as a paragraph. I would recommend always closing your <p> tags with a </p>, it's just good practice. The line-break tag <br /> is likewise self explanatory. It creates a line-break in a series of text or paragraph. The difference here is in semantics vs. presentation. A paragraph tag is a semantical tag, while a line-break tag is a presentational tag. A paragraph tag provides meaning to the content it encloses, while a line-break tag does not. It should be noted that any tag that must be closed within the start tag (as in there is no end tag), such as <br />, should have a space before the closing "/>".

By using the correct markup you are providing meaning to your code/content beyond the presentation layer, which should be solely constructed using CSS. It provides structure to your page and is a very forward looking practice.

An earlier comment stated that IE incorrectly displays paragraph elements... I'd have to disagree. All modern browsers, in fact even most older browsers, display paragraphs correctly. The margins may differ from browser to browser, but they all set default margins on the paragraph elements. This is true of almost all elements that contain content (ie; h1, ul, etc.). It is the author's job to define margins and other attributes to style the elements in a manner to their liking.

Also an "em" is a unit of measure much like a "pt" or "px". It has nothing to do with line-height beyond specifying how "tall" the line-height may be. It can also be used to specify margins, padding, position, letter-spacing, and more.

I'll agree that Mozilla is the best in terms of standards compliance, however IE and Opera don't exactly "suck" at it either. The wonderful thing about the Mozilla (and now Opera), is that they've had the position to entirely recode their browsers, thus being able to steer clear of all the proprietary and incorrect code that inhabits IE and definately NS4. The IE developers on the other hand are having to sort through a few years worth of code. It's not an excuse, but something to keep in mind.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.