What's the proper way to declare an attribute to be false?
In HTML5, you can add the attribute
draggable to any element — it works like
checked; it doesn’t require a value. If you do want to specify a value (e.g. to make it valid XML), I think the official standard syntax is
checked="checked", but other things work too (including
checked="false", confusingly). The standard way to make it ‘false’ is not to include the attribute at all.
<img> elements seem to be ‘draggable’ by default (even if you don’t include a
draggable attribute) – that’s why you get the ‘ghost’ image effect when you drag regular images in web pages. You get this same effect on non-
img elements if you mark them
So how do you disable it on
(From experimenting, I know that
draggable="false" seems to work in Chrome – is that a standard syntax that works everywhere? If so, why doesn’t
checked="false" work the same way?)
2 Solutions collect form web for “What's the proper way to declare an attribute to be false?”
Well, W3C says you’re right; “true”, “false” and “auto” should work (not to say it will everywhere).
Edit: http://jsfiddle.net/nwellcome/DRSbc/ for to experiment with in different browsers.
Take a look here (scroll to ‘Global Attributes’ and click
All HTML elements may have the draggable content attribute set. The
draggable attribute is an enumerated attribute. It has three states.
The first state is true and it has the keyword true. The second state
is false and it has the keyword false. The third state is auto; it has
no keywords but it is the missing value default.
The true state means the element is draggable; the false state means
that it is not. The auto state uses the default behavior of the user
So the answer is: to disable the draggable attribute for a HTML5 element, use