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="" and 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 draggable.

  • how to remove all attributes from <body> with js or jquery
  • How to conditionally add attributes to react DOM element
  • Determning if all attributes on a javascript object are null or the empty string
  • Jquery - hide all elements with ids that exist in a list
  • What is XHTML role attribute? What do you use it for?
  • Dynamically change Tweet Button “data-text” contents
  • So how do you disable it on img elements? You can set the property to false in JavaScript. But what about in the HTML?

    (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?)

  • To use getAttribute(), or not to use getAttribute(): that is the question
  • Access custom attributes via jquery
  • How to add attribute to every table row only when one is hovered (and not the hovered row) via jQuery?
  • jQuery .attr('type', 'submit') on a button element giving me a strange error in IE7
  • Can I specify two attribute at once in D3?
  • set option “selected” attribute from dynamic created option
  • 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 draggable).

    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
    agent.

    So the answer is: to disable the draggable attribute for a HTML5 element, use draggable="false"