When using a br tag, do you use <br> or <br/> and why? and is there a difference?

When using a br tag, do you use <br> or <br/> and why?

Did you try searching for a solution?

2 Likes

When I use a br tag, I use <br>.

<br/> is residue from the XHTML specs, it is not part of the HTML specs. Browsers rendering an HTML page tolerate the trailing slash but it is not within the specifications of HTML. Browsers “forgiveness” does not mean good code.

You will find this stated in several posts within SitePoint, possibly even in earlier topics that you created.

2 Likes

As an aside (off-topic) don’t use a break tag unless its for one of its permitted uses.
I don’t think I’ve used a break tag in the last 10 sites I’ve coded.

The break tag should never be used for making paragraphs or simply spacing out blocks of text,

5 Likes

Both are same.

They do the same job, but they are not the same. One is the HTML version; the other is the XHTML version.

What do you use to do this then? To drop down bellow white space?

Usually vertical margins or padding. In practice, the best choice depends on the layout.

Paragraphs have vertical margins by default, so that should give you a clue what is expected to separate paragraphs.

2 Likes

@asasass: the use of margins or padding (and not <br>) was discussed in another thread of yours just a few days ago.

See How do I set this code up so that the text doest wrap? - #24 by TechnoBear and my next few posts there.

2 Likes

I found this one helpful:
http://www.cssnewbie.com/margins-and-padding-use/#.WKTlAvLYs2x

3 Likes

Using rigid line breaks creates ragged lines when text is displayed with responsive web pages.

Setting line-height and paragraphs may help in aesthetic rendering.

My two Satang :slight_smile:

That’s a nice, clear explanation, @asasass, but I have just a word of caution here. That article dates from 2008, and Web design and development has moved a long way since then. The basic article is OK, but it links to things like “The IE5/6 Doubled Float-Margin Bug”, and suggests using hacks to make IE behave. Neither of those pieces of information are things you need to worry about in 2017, so be careful not to be mislead by reading old resources. Always try to find one which is as recent as possible.

4 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.