Mobile app version of vmapp.org
Login or Join
Angela700

: Why isn't the HTML break tag acceptable anymore for top and bottom margins? I'm starting to think I'm making less with adsense now because of insufficient margins. I tried with CSS margins with

@Angela700

Posted in: #Css #Css3 #Html #Html5 #LineBreak

I'm starting to think I'm making less with adsense now because of insufficient margins. I tried with CSS margins with using the margin and padding properties of applicable elements, but then I noticed something. When I disabled CSS, my page looks mostly like trash with words crammed together, almost no new lines, etc.

Some sources claim never to use consecutive HTML breaks. For example:

<br><br>


The funny thing is when I do add the breaks, the page appears more nicely to users who don't have javascript or CSS enabled.

So my question is, why is using multiple consecutive line breaks in HTML considered a bad practice when it improves accessibility (helps greatly with top and bottom margins for users with limited functionality browsers)?

As a side note, using consecutive line breaks takes fewer bytes than using any other tag that can produce a line break.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

2 Comments

Sorted by latest first Latest Oldest Best

 

@Jamie184

why is using multiple consecutive line breaks in HTML considered a bad practice


Because it breaks the fundamental principle of separation of concerns: by mixing the "content" and "presentation" layers. By using multiple <br>s to create "margins" you are embedding the presentation in the content. To change the "margins" you need to change the content. This ultimately makes the site harder (messy) to update. If sites are harder to update there's more chance of error, etc.


the page appears more nicely to users who don't have javascript or CSS enabled


An extreme (to the point of being non-existent) edge case. Any user that has actively disabled CSS will be used to pages appearing mashed. (How do you disable CSS in the modern browser anyway?) I struggle to imagine that you have real users that are using browsers that are so "limited [in] functionality" that they are incapable of this basic CSS. Any browsers that are purposefully designed to be very limited probably have alternative forms of navigation or are designed to be non-graphical anyway?

It's great to have pages that are at least readable with CSS disabled - it's a sign they are logically structured and are accessible. However, the width of a margin should not matter in this respect. And real users don't surf with CSS disabled.


but <br> is only 4 bytes where as <div ID="X">&nbsp;</div> is almost 25 bytes


You shouldn't be using a DIV either. For "margins" you should be using CSS. If these margins are so critical to the layout then include them as part of an embedded stylesheet in the HEAD section - that way they are loaded with the page and the user cannot see a delay. (Whilst developing you still keep the embedded stylesheet external - separation of concerns - and embed it using a server-side technology when the page is served.)

10% popularity Vote Up Vote Down


 

@Connie744

Because a line break is used to break a line and not add margin. The effect may appear the same but the semantics are not. If you want a margin on a div, use "margin".

You have people who turn CSS off? I doubt that. You have visitors with javascript turned off? Those who know how to do that are the same who know what to expect as a result.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme