A question has rised in my project team as we are designing a web page. Can we use white characters (like space) in the name attribute of an HTML element ? eg. <input type="checkbox" name="first check box">
My concern is mainly the behavior of different browsers with such an attribute value.
We are now in the design phase, until we get to write some code and test this, a long time will pass, so I am asking you experts about this.
Thank you !
Rule 6: Tag Names Cannot Contain Spaces.
The HTML interpreter ignore white spaces by default. HTML ignore any space added after the first space between words. Any space at the start or end of a HTML tags is completely ignored. HTML interpreters also ignore line breaks by default.
To insert blank spaces in text in HTML, type for each space to add. For example, to create five blank spaces between two words, type the entity five times between the words. You do not need to type any spaces between the entities.
Whitespace refers to characters which are used to provide horizontal or vertical space between other characters. Whitespace is often used to separate tokens in HTML, CSS, JavaScript, and other computer languages.
Yes.
The name attribute contains CDATA. It can be more or less anything you like. (You shouldn't include leading or tailing white space because user agents can ignore it, but white space in the middle is fine).
Note that name
attributes do not have NAME tokens as their data type (although the id
attribute does (the id
attribute doesn't take an ID token)), so you don't have the restrictions imposed on NAME tokens.
Most browsers will handle this fine, as long as they are properly quoted. However, for sake of eliminating corner cases, it's much wiser to user CamelCase and avoid the probability of browsers not handling it correctly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With