I use quantity input field for product and don't want to allow any interaction with it:
<input id="product-qty" type="number">
My CSS is the following:
#product-qty {
pointer-events: none;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
But it's not enough, when I TAB, I can select quantity field and then do any keyboard entry I please. I can accept selecting quantity field, maybe it's even good accessibility-wise, but can't allow to enter or remove anything.
I know how to solve it with JavaScript, what I want is to know whether it's possible with CSS only and if yes - how to do it.
readonly?readonlychanges element's html, what will require JavaScript in my case, I guess I will finally be forced to do so, however even withreadonlyand all CSS rules in my original post, I can still select input with tab and as I mentioned I can accept highlight around the field, but it also highlights quantity..readonly-qty::selection { background: transparent; } readonly-qty::-moz-selection { background: transparent; }, I guess I'll need JS to add classreadonly-qtyanyway, but at least it works and withreadonlyI don't needpointer-events: none;, so title displays correctly without workarounds.