Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

BR element sucks!

DZone's Guide to

BR element sucks!

· Web Dev Zone ·
Free Resource

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

You know how it goes. Designer creates the design templates or whatever and then developers have their say. Sometimes, it happens that they mess up something. Among many design issues caused by developers, one in particular really drives me me nuts - incorrect usage of <br/> element. I often find that <br/> element is being used to create layout. And this is simply - incorrect.

Element <br/>, or line break element produces a forced line break (carriage-return) in text. So you use it in text. If you use <br/> element to make a space between other elements, e.g. input fields and buttons, you can mess up the design. If you separate input fields wit line breaks you make the designer's work harder if he/she wants to change the layout. Let's see the following example:

[img_assist|nid=5851|title=|desc=|link=none|align=none|width=305|height=130]

If you do things this way, you might make it impossible to restyle the layout. If, for example, designer wants to move Login button to the right of the password field, this won't be possible using simple CSS. Not to mention if HTML code is being generated on the server - even worse. Instead of this, you can easily get the same visual effect if you apply some CSS styles:

[img_assist|nid=5852|title=|desc=|link=none|align=none|width=305|height=130]

So, if you want to style web form, use CSS, use margins or padding. These things should be set through CSS. Period. Did you ever notice the same thing? How do you deal with this issue?

Deploying code to production can be filled with uncertainty. Reduce the risks, and deploy earlier and more often. Download this free guide to learn more. Brought to you in partnership with Rollbar.

Topics:

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}