|
|
|
|
|
by Nadya
3888 days ago
|
|
>You should write your markup in the clearest, most semantic way possible Semantically is exactly why data-* should be used instead of classes. But semantics often include a bit of extra work (adding a data-filter attribute instead of just throwing an extra class in the mix) and so people throw them aside all too often. >I still don't buy the argument, as you can just write a short helper function that makes things just as easy as selecting with dataset. So to avoid doing things the proper way you would write a helper function to get around a problem? The CSS can be written both ways (you can use [data-filter="..."] as a selector). The difference is between using data-* or adding a class. The difference between the two comes down to semantics and in some niche scenarios the ability to easily change the value. |
|