permaculture playing cards
The moose likes HTML, CSS and JavaScript and the fly likes Disable html elements using CSS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Disable html elements using CSS" Watch "Disable html elements using CSS" New topic

Disable html elements using CSS

Rajeev Ravindran
Ranch Hand

Joined: Aug 27, 2002
Posts: 455
Is it possible to disable html elements ( text field, drop down) using CSS ? i know its possible using Java Script , just wondering if its possible using CSS; it is a requirement related to JSF , so if CSS can do the job it will make my job easy

Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
it does not need JavaScript and you can not do it with CSS

The elements have an attribute disabled which you need to set.

Linda Walters
Ranch Hand

Joined: Apr 30, 2005
Posts: 100
The "when" and "how" of disabling them is what is important here.

For example, if the user selects a certain item from a combobox that may, depending on the value, enable or disable certain other HTML tags on the page. This should be done with a JavaScript function that changes state of the disabled attribute of form tags or even the visibility of other HTML tags.

If you are sending an entire page from the server via JSP/JSF or just by composing HTML in Java or with XSLT, then you should set this in the server. However it is initially set, if there is a possibility that the user can do something that will change it, then you should have the JavaScript option too.

Just my $0.02 worth.

<a href="" target="_blank" rel="nofollow">Javaville Gazette</a><br />Non-cooperation with evil is a duty. -- Mahatma Gandhi
I agree. Here's the link:
subject: Disable html elements using CSS
It's not a secret anymore!