When writing clean and well-readable code in html, how to handle strings and spaces
for example, if I use break for the next line, there is extra space between
<style type="text/css"> a {margin:0px; border:1px solid #666; padding:10px; text-decoration:none;} </style> <div> <a href="#">Test 1</a><a href="#">Test 2</a> <a href="#">Test 3</a> <a href="#">Test 4</a> </div>
jsFiddle
so what should i do
is there a standard way to handle this, or I just have to write all the html code in 1 line if I don't want the space and the gaps between the tags to be executed as
EDIT:
Thank you guys, but I already know that extra spaces are compressed into one and how (enter) acts, the problem is that I do not want to enter this way (we put a space between my tags, because then I need to transfer this space to my style), so I donβt need to write code on the same line (I want to write it clean and readable)
EDIT 2:
I think I need to solve the issue a little
I need this code:
<div> <a href="#">Test 1</a> <a href="#">Test 2</a> <a href="#">Test 3</a> </div>
which will be displayed (seen by the user), and act like this code: (there is no additional gap between them due to line breaks or spaces)
<div> <a href="#">Test 1</a><a href="#">Test 2</a><a href="#">Test 3</a> </div>
this extra space is causing me a lot of problems,
is there any solution for this? perhaps stylize the body so as not to count the space and enter between the tags (not between the text inside the tags, of course) "as a space as a result?
DECISION
Reading the answer of the main answer to the last part, he mentioned float, so just adding float: left; to my code above my problem is solved
Online: jsFiddle
code:
<style type="text/css"> a {float:left; margin:0px; border:1px solid #666; padding:10px; text-decoration:none;} </style> <div> <a href="#">Test 1</a><a href="#">Test 2</a> <a href="#">Test 3</a> <a href="#">Test 4</a> </div>
UPDATE (OTHER DECISION):
I tried other methods, and I think display: table-cell; - the answer is also, and maybe even better, because after that we do not need to clean
The only drawback is that it will not work on IE 7 and earlier, although I believe that it is controlled using a simple lt IE 8 hack
jsFiddle