I am trying to make readonly, but not disable, all types of form element only using css and html (i.e. no javascript).
Some things (like inputs) are easy - the readonly
attribute on the input does it. For other things, like checkboxes and selects for example, readonly
doesn't work. I can use css pointer-events: none
to prevent clicking on it, but I haven't found a keyboard-events: none
or similar that I can use to stop people getting to it with the keyboard and changing it.
I know of several ways to achieve this with javascript, but I'm hoping to find one that is javascript free.
tabindex="-1"
attribute – Bobbee