The difference is you are using markup to accomplish a completely presentational task ( which as you know isreally frowned upon, if you can avoid it.)
This is OK:
<h1>My title:<br /> Some tile words</h1>
This is weak code:
<h1>My title:<br /><small> Some tile words</small></h1>
<h1>My title:<small> Some tile words</small></h1> / tag small {display:block;} would be the best practice.
The only way to tell if a BR is totally unavoidable, would be semantics; I just cant think of an example where you couldn’t AT LEAST use a SPAN instead of a BR .
At one level it is really a question of appropriateness of mark up. You should use mark up that is appropriate to the situation. The classic ‘no no’ is the use of a tables for layout.
In the example you have given the <br> would seem entirely appropriate.
If you did use a <div> the you could style it (padding, margin, colour, font etc) but that’s about the only advantage.
I still use <br /> myself as I haven’t really come across many people telling me I shouldn’t or making references to avoiding it. Though the two examples presented in this thread seem like viable options…
a br’s use is that of a line beak. If you need a line break then it is the preferred tag to do so. You can wrap each in a span or whatever and say display block do do it the css way instead. Each is acceptable and neither has pros or cons vs. I use br’s as that is what they are intended for.
Song lyrics are the typical correct use of BR where a forced line break is usually desired for obvious reasons and sometimes with forms they tend to make things slightly easier on rare occasion. The markup is always hardcoded and in play whereas the CSS is presentational such as line spacing effects, etc.
Different views are what you get in a forum -we don’t always have to agree though:). There can be good arguments on both sides so don’t be swayed by mine or anyone else’s but make your own mind up.
BTW, so why is it that I couldn’t get the Date to “hug” the Location when I had a <br />?
Probably the default line height for the break coming into play. Breaks can be hard to control if you want pixel precision.
<br> is for line breaks. What you have is a line break.
The idea of using CSS for presentation is there to HELP you, not to force you to obey some rules other people make and force you to live under their rule, to your own detriment. CSS makes site-wide maintenance easier. Do you break address lines in many many pages? In other words, do you have that convention of presenting an address on two lines on alot of pages, and do you see yourself changing that in the future? If you use the block idea, in the CSS you could simply remove that block, and all those line breaks in all those addresses will bump back up. Easy change.
But do you have one address on one page you are breaking? If so, maybe it is better to use a line break. But then think whether or not you will expand the page to include many many addresses with two line breaks, that may eventually have one line. Just make sure CSS and HTML is helping your project, not hindering you just because some purists have a Golden Calf.
I would imagine that someone that disables CSS would expect minor differences. If they’re taking the styling out of the rest of the page do you think they’ll mind the city on the same line as the date?
What I am still wondering is why so many people write a line break as <br /> when in HTML the tag is <br> and in XHTML it is <br/> (no space). The space is only needed for XHTML served as HTML to Netscape 4 users. Do all these people using <br /> really have that many visitors still using Netscape 4?
My point wasn’t really that users will disable css but more that you can get a good idea of the structure of your page by turning css off. If the html is logical and sensible you can get well laid out and readable text. If the whole site is one long line that stretches into infinity then you are doing something wrong
It shouldn’t really be of prime importance that pages work with css turned off but it’s a good tool to use occasionally - just like switching images and js off which a lot of advanced users do anyway.
To be honest it’s not an earth shattering decision whether you use a break or a span in the above scenario but is is wrong to use breaks just to make space. Breaks have a meaning and should be used where required.
Yep, the whole point of my Release #2 is to streamline my code…
To be honest it’s not an earth shattering decision whether you use a break or a span in the above scenario but is is wrong to use breaks just to make space. Breaks have a meaning and should be used where required.
Well Paul, oddz recently said…
On a scale of 1 – 10 the things you always seem to get caught up on are a 1… maybe a 2.
Man… if you working in the industry you would be making about a dollar an hour in regards to how much you concern yourself with micro issues.
As the saying goes, “Do one thing, and do it better than anyone!”
(Hey, I’m an Analyst by day. What else would you expect?!)