HTML 5

HTML ReadOnly vs Disabled

By Niall Kader1 min read

This would be a good trivia question for web geeks...what's the difference between setting readonly=true and disabled=true on an input element?

Answer:

disabled doesn't get submitted in form post

disabled controls won't receive focus (and are excluded from tabbed navigation)


both should prevent the keyboard from appearing when the user tries to enter data into the input on a touch screen

not all elements use readonly, such as SELECT, BUTTON, and OPTION

setting readonly to true will not change the visual appearance of the control, which may sometimes be confusing. Disabled will often make the input color change.