title: Hide table rows using pure CSS3 in Bootstrap datatable
body: <p>I use Bootstrap with datatables and would like to hide specific table rows using pure CSS, <em>without</em> any JavaScript / jQuery.</p>
  
  <p>I thought, I can do it like this, but it doesn't work, unfortunately:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>input[name=hide_rows] + table tr.hide-this-row {
          display: table-row;
  }
  
  input[name=hide_rows]:checked + table tr.hide-this-row {
          display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="form-group"&gt;
   &lt;label for="hide_rows"&gt;Hide rows?&lt;/label&gt;
   &lt;input type="checkbox" id="hide_rows" name="hide_rows" checked&gt;
  &lt;/div&gt;
  
  &lt;div class="table-responsive"&gt;
   &lt;table class="table table-condensed table-hover" id="some-table" data-order='[[ 0, "desc" ]]'&gt;
    &lt;thead&gt;
     &lt;tr&gt;
      &lt;th&gt;Head #1&lt;/th&gt;
      &lt;th&gt;Head #2&lt;/th&gt;
      &lt;th&gt;Head #3&lt;/th&gt;
     &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
     &lt;tr class="show-this-row"&gt;
      &lt;td&gt;Row #1&lt;/td&gt;
      &lt;td&gt;Row #1&lt;/td&gt;
      &lt;td&gt;Row #1&lt;/td&gt;
     &lt;/tr&gt;
  
     &lt;tr class="hide-this-row"&gt;
      &lt;td&gt;Row #2&lt;/td&gt;
      &lt;td&gt;Row #2&lt;/td&gt;
      &lt;td&gt;Row #2&lt;/td&gt;
     &lt;/tr&gt;
     
     &lt;tr class="show-this-row"&gt;
      &lt;td&gt;Row #3&lt;/td&gt;
      &lt;td&gt;Row #3&lt;/td&gt;
      &lt;td&gt;Row #3&lt;/td&gt;
     &lt;/tr&gt;
     @endforeach
    &lt;/tbody&gt;
   &lt;/table&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Please note, that Bootstrap and the datatable is adding some <code>divs</code> there and at the end, it has some more HTML tags between.</p>
  
  <p>That's the reason, why I don't would like to use this solution:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>input[name=hide_rows] + div &gt; div &gt; div &gt; table tr.hide-this-row {
          display: table-row;
  }
  
  input[name=hide_rows]:checked + div &gt; div &gt; div &gt; table tr.hide-this-row {
          display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="table-responsive"&gt;
   &lt;label for="hide_rows"&gt;Hide rows?&lt;/label&gt;
   &lt;input type="checkbox" id="hide_rows" name="hide_rows" checked&gt;
  
   &lt;table class="table table-condensed table-hover" id="some-table" data-order='[[ 0, "desc" ]]'&gt;
    &lt;thead&gt;
     &lt;tr&gt;
      &lt;th&gt;Head #1&lt;/th&gt;
      &lt;th&gt;Head #2&lt;/th&gt;
      &lt;th&gt;Head #3&lt;/th&gt;
     &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
     &lt;tr class="show-this-row"&gt;
      &lt;td&gt;Row #1&lt;/td&gt;
      &lt;td&gt;Row #1&lt;/td&gt;
      &lt;td&gt;Row #1&lt;/td&gt;
     &lt;/tr&gt;
  
     &lt;tr class="hide-this-row"&gt;
      &lt;td&gt;Row #2&lt;/td&gt;
      &lt;td&gt;Row #2&lt;/td&gt;
      &lt;td&gt;Row #2&lt;/td&gt;
     &lt;/tr&gt;
     
     &lt;tr class="show-this-row"&gt;
      &lt;td&gt;Row #3&lt;/td&gt;
      &lt;td&gt;Row #3&lt;/td&gt;
      &lt;td&gt;Row #3&lt;/td&gt;
     &lt;/tr&gt;
     @endforeach
    &lt;/tbody&gt;
   &lt;/table&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I don't like this solution as you have to count and add that much <code>div</code>s as there are between and I also had to move the checkbox outside the <code>&lt;div class="form-group"&gt;</code> and inside the <code>&lt;div class="table-responsive"&gt;</code>.</p>
  
  <p>It would be much better, if there is an easier solution like the below code for the first shown HTML code:</p>
  
  <pre class="lang-css prettyprint-override"><code>input[name=hide_rows] + * table tr.hide-this-row {
          display: table-row;
  }
  
  input[name=hide_rows]:checked + * table tr.hide-this-row {
          display: none;
  }
  </code></pre>
  
  <p>The last CSS code is not working, unfortunately.</p>