Can I use non existing CSS classes?

I have a table where I show/hide a full column by jQuery via a CSS class that doesn’t exist:

<table>
   <thead>
      <tr>
         <th></th>
         <th class="target"></th>
         <th></th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td></td>
         <td class="target"></td>
         <td></td>
      </tr>
      <tr>
         <td></td>
         <td class="target"></td>
         <td></td>
      </tr>
   </tbody>
</table>

With this DOM I can do this in one line via jQuery: $('.target').css('display','none');

This works perfectly, but is it valid to use CSS classes that aren’t defined? Should I create an empty class for it?

<style>.target{}</style>

Are there any side effects or is there a better way to do this?

13 Answers
13

Leave a Comment