Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding form drop down options using ONLY CSS

Tags:

css

forms

I am definitely a CSS noobie, but have looked everywhere and can't find a solution to my problem (I have found out why my attempts don't work, but no solution).

I am hacking a CSS sheet to modify an advanced search form which is linked to a database. I CANNOT touch the HTML, nor can I use JavaScript or JQuery. The search form allows a user to select which fields they wish search from a drop down form menu. I want to hide a number of field options since they have no data. The HTML is

<div class="inputs"><div class="search-entry">      
                <select name="advanced[0][element_id]"     
id="advanced-0-element_id">
<option value="" label="Select Below ">Select Below </option>

<optgroup label="Dublin Core">
<option value="88" label="Abstract">Abstract</option>
<option value="98" label="Access Rights">Access Rights</option>
<option value="118" label="Accrual Method">Accrual Method</option>
<option value="119" label="Accrual Periodicity">Accrual Periodicity</option>
<option value="120" label="Accrual Policy">Accrual Policy</option>

and so on I tried

option [value="88"] {
display: none;}

But this doesn't work b/c each drop down option does not create a block in the first palace. Therefore display: none can't hide a block that doesn't exist.

So now you know what doesn't work, and what I need to do. Any suggestions? Again, I can't access the html code at all b/c it is generated by a PHP program on a server I don't have access to. Even if I did, I don't know any PHP at all.

thanks for your time

like image 390
christine Avatar asked May 23 '11 15:05

christine


People also ask

How do you hide a drop down list in CSS?

Answer: Use the CSS :hover pseudo-class If you simply want to show and hide dropdown menu on mouse hover you don't need any JavaScript. You can do this simply using the CSS display property and :hover pseudo-class.

How do I hide a dropdown?

You can hide the dropdown arrow from the DropDownButton by adding class e-caret-hide to DropDownButton element using cssClass property.

How do you hide a form in CSS?

You can hide an element in CSS using the CSS properties display: none or visibility: hidden . display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping the space the same.

How do I hide a drop down list in HTML?

The drop-down is used to create a list of items that need to select an element. We use <select> and <option> elements to create a drop-down list and use disabled attribute in <select> element to disable the drop-down list element.


1 Answers

At the risk of getting downvoted I am going to say that this isn't possible with CSS alone.

The option tag describes the data model of an HTML element. The style sheet describes the view.

like image 191
maple_shaft Avatar answered Nov 23 '22 07:11

maple_shaft