Storing data attributes in the 'class' and in HTML5 data attributes

Can anyone suggest an opinion on whether it is better to use the Rails conventions provided in attributes dom_classand dom_idfor semantic helpers such as div_for, rather than HTML5 data attributes such as "data-class" or "data" -id?

those.:

<div id="post_550" class="post">

against

<div data-class="post" data-id="550">
+5
source share
1 answer

Only one opinion ...

  • If you are doing css formatting, use div.class.
  • But if you are doing javascript, then I think the html5 attributes make sense.

, - , - . / .

+4

All Articles