简体   繁体   中英

What does a reference inside a div tag without an attribute do?

I would like to start using Attribute Selectors in my css. I am seeing div tags that contain a reference WITHOUT any attribute statement like:

<div class="container" data-footer>

All my searches (for the last hour) to find out how "data-footer" can be listed without the use of an attribute= (eg, id= or class= or etc.) have resulted in no information. Dozens of SO and Google links without a single example of a reference inside a div tag without the use of an attribute. Because I do not know what this is (or what to call it) I'm probably not searching with the right keywords. Is this a short-form way to pass an id or???

Data- attributes without a value can be used as Boolean. For example:

if(div.hasAttribute('data-footer')) {
   // then do something
}

In css you can access it like:

div[data-footer] {

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM