Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML / CSS hide checkbox

How can I hide a checkbox using HTML / CSS?

Let's say I have

<table>
    <thead>
        <th>
         Col A
        </th>
         <th>
         Col B
         </th>
    </thead>
    <tbody>
        <tr>
            <td> <input type="checkbox" class="hidden"> Some stuff </td>
        </tr>
         <tr>
            <td> Some Other stuff </td>
        </tr>
    </tbody>
</table>

The name and the values of the checkbox are not constant. I know there's some way with jquery but is there a way to hide it with pure CSS or HTML?

like image 469
Wistar Avatar asked May 15 '14 15:05

Wistar


People also ask

How do I hide a checkbox label?

Wrap the entirety with a label which will then allow you to use style="display:none to hide the label . You also used status instead of style but by using the code above you'll do fine.

How do I disable a checkbox?

The disabled property sets or returns whether a checkbox should be disabled, or not. A disabled element is unusable and un-clickable. Disabled elements are usually rendered in gray by default in browsers. This property reflects the HTML disabled attribute.


1 Answers

Please keep in mind that setting the display property to none, makes the element inaccessible using tabs (see: Checkbox tab index not working when set to hidden with custom design). If you case about accessibility, you can use:

input[type=checkbox].hidden{
  opacity: 0;
}
like image 108
codeorelse Avatar answered Oct 12 '22 13:10

codeorelse