treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Disable input using CSS

  • Does anyone know if there is something tricky I can do to disable a form input using CSS? I'm building a Wufoo form, so I don't have access to the HTML attributes and JavaScript isn't at my disposal either.
  • You could use pointer-events: none; but it won't work in IE or Opera.

    Another option you have is to position an element over the top of the input. You can do this using pseudo-elements, but only on the parent element, as the input itself can't have pseudo-elements: http://jsfiddle.net/joshnh/DcQ8N/

    Keep in mind that this won't work in IE7 or below, and that this might also affect other child elements.

  • <input type="text" disabled />



    This will work in ie8 and ie9 too.

    or you can also do some css :


  • input[type="text"]:disabled
    {
    background:#dddddd;
    }