Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element ID in HTML Document ~ Naming Question

Are there any issues (either technically, or otherwise) with putting a space character in an element ID? For example, something like this:

<li id='something with spaces'>Test123</li>

I understand that this is NOT desirable (I have never used spaces before), but I have hit a scneario where I need to do this if possible.

What are the potential issues (if any) I may face with scaling, any particular browsers, scripting, or CSS styling?

Are there any articles that talk about the 'bad characters' that CAN be used but SHOULD NOT be used?

Thanks -

like image 522
OneNerd Avatar asked Dec 11 '25 04:12

OneNerd


1 Answers

Per the standard,

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

By breaking this rule you'r likely to run into no end of trouble from standard-complying processors of your (invalid) HTML. So, I would recommend you don't do this.

like image 67
Alex Martelli Avatar answered Dec 12 '25 19:12

Alex Martelli