Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any difference for data-attribute=false with data-attribute="false" in html element?

Tags:

html

I have data attribute in html element as <button data-verified=false>Update</button>. It have boolean value for data attribute.

Is there any difference with following element <button data-verified="false">Update</button> as the data-attribute is wrapped with double quotes.

Is boolean values are supported in html?

like image 772
Justin John Avatar asked Mar 24 '23 16:03

Justin John


1 Answers

Boolean attributes are supported in HTML, but data-verified isn't one of them, no matter how it appears in the markup. data-verified=false and data-verified="false" both create an attribute of the type string and value "false", which if tested in JS as a boolean will be treated as true

This is only the case because false doesn't contain spaces. As a contrary example, data-verified=not true is invalid and not at all the same as data-verified="not true"

like image 155
Alohci Avatar answered Apr 25 '23 15:04

Alohci