Spaces and newlines with HTML and CSS

Should I use <br /> and &nbsp; in HTML to place elements, or do I just need to use CSS mapping: inline with pad / mark for positioning and the whole style? what are the pros and cons with both?

+4
source share
6 answers

Use <br> to represent a string in a block element and use &nbsp; to represent non-breaking space inside an inline element. Nothing else. For the rest, just use CSS in a smart way with each of the display , float , padding and / or margin properties.

+6
source

<br /> has its uses, but if you use   lot, I would think about finding better ways to reconcile. &nbsp; just ugly and clumsy.

If this is tabular data, use a table. Your life will be much happier.

If this is not tabular data, use css as BalusC suggests.

+4
source

Ideally, you should position everything with css and use <br /> (line break) and &nbsp; inside <p>s . But this is not an ideal world;)

+1
source

<br /> Really can go anyway. But if you find that you use it to adjust the paragraph spacing or something like this, you really need to ask yourself: "Is there a reason why im uses breaks instead of using the class to adjust the margins?" &nbsp; on the other hand, it’s rare if it ever makes any sense out of a paragraph ( <p /> ) and for half the time when they are used little for it, anyone like using text-indent is preferred for indenting the first paragraph and a lot to the editors chiger everywhere, completely contradicting the double space preceding the appearance on the Internet - as far as this is concerned, this is only a printed version.

+1
source

In HTML5, you also have the new http://html5doctor.com/element-index/#w

the answer is not black and white, it depends on your content, sometimes it should be, and in some cases, therefore, the content will be on the same line.

if you want to use it as a block you can use

0
source

Using CSS fields and indentation will give you more flexibility for making adjustments later.

0
source

Source: https://habr.com/ru/post/1299783/


All Articles