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

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

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?

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:

Published at DZone with permission of Janko Jovanovic. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}