Checkbox in a CSS table won't show at minimal width

Similar to my question in May 2016, I’d like to use a CSS table, but for some checkbox options this time…

Problem seems to be that the < input > element seems to have some properties that I have to address for it to respond to the width:1%; command…?

It is now claiming about half the width of the table and I can’t get it to become narrow…

I tried a bunch of things, but it’s become wild guessing for me…

TIA! :slight_smile:

<!doctype html>
<meta charset="utf-8">

.cssTable {
	margin:0 auto;
	padding:.375em 0 0 0;
.cssTable li {
.cssTable li span {
	padding:0 0 .25em 0;
	color: #000;
	width:1%;	/* shrink cell to content width */



<ul class="cssTable">
	<li><span><input type="checkbox"></span><span>option 1</span></li>
	<li><span><input type="checkbox"></span><span>option 2</span></li>


You have assigned a width of 100% to the table. The cells respond by filling that width in proportion to their assigned widths. Like speed limits, when the table has been assigned a width, cell widths are only a suggestion. :slight_smile:

put an outline around the spans to visualize the cells.
outline:1px dashed blue;

1 Like

My question is, “why does this ‘shrink cell’ trick work perfectly, for example, for an icon, and probably text, but not for this input element?”

I’m using the exact code with great success, but the input element makes it fail somehow…

I think I found the solution…

I’m putting the ‘shrink cell’ code on the first span only now. It should probably not be on both cells, I guess…

.cssTable li span {
	padding:0 0 .25em 0;
	color: #000;
.cssTable li span:first-of-type {width:1%} 

Thanks for your reply! :slight_smile:


No, because both cells would be the same width and as the table is 100% then they both stretch accordingly. If you shrink just one cell with the width then the other cell takes up all the slack automatically.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.