D
D
Dmitry Petrov2015-03-19 21:39:22
css
Dmitry Petrov, 2015-03-19 21:39:22

Why does line wrapping in code affect page appearance?

Hello. The question arose: why such a code:
<button ></button><input>
And such a code:

<button ></button>
<input>

give different results? This refers to the space between the button and the input that appears in the second case. Can this be fixed somehow and should it be like this?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey Mokhov, 2015-03-19
@mokhovcom

button and input have display: inline-block by default, so they behave somewhat like plain text on the page, hence:
merged
text separate text

O
Optimus, 2015-03-19
Pyan @marrk2

Because spaces and line breaks are also characters and they count. The document needs somewhere to store the information that "there are 2 spaces and here is a line break" so it stores it :)

M
mayorovp, 2015-03-20
@mayorovp

Why this is so, has already been written above. You can fix this with a zero font size - but it's better to just use the first option.

N
Nikita K., 2015-03-20
@bonilka

You can also write

<button ></button><!--
--><input>

and the reasons have already been written

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question