If you have a snippet in a StackOverflow post and you hit the Tidy button, the result is not always equivalent to the original!
Take this snippet for instance
<input name = textbox>
Then if you hit Tidy, the result is as follows.
<input name=t extbox>
That is, whenever an attribute value is unquoted and is preceded by one or more spaces, tidy inserts a space after the first letter of the value.
(Note that while unquoted attribute values are not recommended, they're perfectly valid HTML, as is using spaces around the =
sign.)
Can this be corrected?
=
and the attribute value isn't quoted. e.g.<input name= textbox>
<input name="" textbox>
. Any value with a space, after the=
, is an attribute (when unquoted). The tidy function is trying too hard to removetextbox
from being an attribute to being a value, when it should give it just a pair of quotes (to indicate an empty attribute). Consider this:<input type=checkbox checked= disabled>
. What do you expect? I expectchecked
to have an empty string, as it should be parsed. That example should produce<input type="checkbox" checked="" disabled>
.attr=value
means exactly the same asattr= value
. See the official parsing rules.<meta>
tags, hence the inclusion of those pseudo-parsing rules there). That said, the actual HTML attribute syntax does also clearly permit whitespace around the=
sign.<input name = textbox>
may be valid but I am consumed by physical revulsion when I look at it. Maybe the Tidy engine feels the same?