Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spaces between html attributes and values?

Are they allowed? and do they work with all browsers?

Example:

<div role = "region"
     id = "some-id"
     class = "a-class another-class">
like image 742
Ian Storm Taylor Avatar asked Aug 15 '11 10:08

Ian Storm Taylor


2 Answers

Yes they are, and they will work in all major browsers, although I would say it should be considered bad practice to include unnecessary white-space as it pointlessly increases the size of the document.

HTML, XHTML, XML and others are all variants of SGML, so if you want to know what is/isn't allowed in general, have a look at that specification. You should always pass all your documents through the W3C markup validators to ensure they are valid.

like image 39
DaveRandom Avatar answered Sep 22 '22 06:09

DaveRandom


Yes, any amount of whitespace is allowed and will work in all browsers.

One consideration - this will add to the page size, so if bandwidth and performance are concerns, try to limit the amount of whitespace you use.

like image 117
Oded Avatar answered Sep 23 '22 06:09

Oded