For examlpe, if I have this:
<div id="blah" myattribute="something">whatever</div>
Can I be safe that no browsers will ignore (and thus render inaccessible from legacy JavaScript) the myattribute
? I am aware that this is ugly and not standard, but is quite useful. Or if they do, would jQuery still be able to get them?
Unrecognized HTML elements are treated by the browser as anonymous inline elements (effectively inline elements with no semantic value, similar to <span> elements). You can still refer to them by their names, and style them with CSS, for example — you just need to make sure they are behaving as you want them to.
In XHTML and in HTML5 (even in HTML serialization), both <abc> and <123> are invalid. In HTML 4.01, <123> is valid, though not recommended, and it simply means those five data characters.
This means that the URL in question has defined the language/region attribute using HTML lang, but either the language code or the geography code is invalid (or both are invalid).
You should use data
attributes, they're web standard.
Like this:
<div id="blah" data-myattribute="something">whatever</div>
Then in jQuery you can do:
var value = $("#blah").data("myattribute");
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