css-selectors

CSS more short query

For example I have a CSS selector: #spotlightPlayer .container .commands.over span, #spotlightPlayer .container .commands.over ul, #spotlightPlayer .container .commands.over ul li { clear:both } Is there a way to write like, (#spotlightPlayer .container .commands.over) span, ul, ul li { clear:both } ...

In CSS what is the difference between "." and "#" when declaring a set of styles?

What is the difference between "#" and "." when declaring a set of styles for a particular element? Here are two examples. .selector { background-color:red; property:value; } #selector { background-color:red; property:value; } ...

Auto ajax selectors with Jquery

Hi, I'm trying to make a proof of concept website, but I want perfect degradation. As such I'm going to code the website in plain XHTML first and then add classes & ids to hook them in jQuery. One thing I want to do is eventually enable Ajax xmlhttprequest for all my links, so they display in a viewport div. I want this viewport to be a...

Speed/redundancy of selectors in CSS

Does anyone have information on browser selector speeds in CSS? In other words, how different selectors compare to each other (in th same browser). For example, I often see (and write) code like this: #content #elem { ...rules... } But since those elements are unique IDs, I should only need #elem, right? This got me thinking about wh...

Apply CSS Style to child elements

I want to apply styles only to the table inside the DIV with a particular class: Note: I'd rather use a css-selector for children elements. Why does the #1 works and #2 doesnt? 1: div.test th, div.test td, div.test caption {padding:40px 100px 40px 50px;} 2: div.test th, td, caption {padding:40px 100px 40px 50px;} HTML: <html>...

Styling Nested Lists in CSS

I would like to build a tree like navigation interface in pure markup (that is, without needing javascript/jquery etc.). Unordered lists <ul> seem like the best solution, and I have found this tutorial on simplebits.com is very close to the solution I need. However, the author defines the stylesheet with the assumption that the final...

How to workaround: IE6 does not support CSS "attribute" selectors

One of the projects which I am working uses CSS "attribute" selector [att] CSS Selectors which is not supported by ie6: Support for CSS selectors in IE6 (look for text "Attribute Selectors") Is there any workaround/hack which is of course valid html/css to overcome this problem? ...

Is there a way to query for element with multiple classes in CSS?

How do I query for an element that have two classes at the same time? For example: <div><span class="major minor">Test</span></div> I want to style all the spans that have "major" and "minor" classes at the same time. ...

Negative CSS selectors

Is there some kind of "negative" CSS selector? For example when I write the following line in my CSS, all input fields inside an tag with class classname will have a red background. .classname input {background: red;} How do I select all input fields that are OUTSIDE of a tag with class classname? ...

How is the angle bracket character, ">" used in CSS?

I have seen this character a number of times in CSS files but I have no idea how its used. Can anyone explain it to me and show how they are useful in making a page style easier? ...

How can I force Internet Explorer to apply CSS styles

I have a couple of CSS selectors like this: table.SearchCustomerResults > thead > tr > th[sortOrder="0"] {} table.SearchCustomerResults > thead > tr > th[sortOrder="1"] {} then I set the sortOrder extension attribute for each of the cells in JavaScript. However, the changed style is not visible in the browser (IE7, perhaps other) unti...

PrototypeJS: Selecting visible elements

I am trying to formulate a selector to select a set of visible elements. Our application uses the Prototype JavaScript framework, version 1.6.0.3. The markup I'm working with is as follows: <ul> <li style="display:none;">1 Hidden</li> <li style="display:none;">2 Hidden</li> <li style="">3 Visible</li> <li style="display:none;">4 Hi...

Can we use CSS 2.1 selectors in practice?

The main culprit behind this question is of course IE6, (almost) everybody agrees that a website should support IE6 since it is used by more than 15% of the visitors (for Yahoo it is still an A-Graded browser). IE6 doesn't support CSS 2.1, so can we use CSS 2.1 selectors in our stylesheets? Let me give an example: <body> <div class...

Why can't you group descendants in a CSS selector?

If you want to assign the same style to a group of descendants, why isn't there an easy way to do this with CSS? Say you have an HTML table as follows: <table id='myTable'> <tr> <th></th> <th></th> <th></th> </tr> . . . <tr> <td></td> <td></td> <td></td> </tr> </table> Why do you have to style al...

How would I style the text following a :checked radio button?

I've tried the following: :checked + * { font-weight: bold; } With the following html: <p><input type = "radio" name = "blah" />some text</p> How would I go about styling such text? Solution: Throw label tags around the text, and select with :selected + * It works in opera and ff3, so I'm good. ...

css selector rules --ruleset for all elements within a selector?

With at-rules, it's possible to have a ruleset for elements during that at-rule event (like printing, mobile devices, etc.) But what about just for a specific selector? I am working on a sub page of a larger site, and I have to use the master stylesheet for any of my pages. Sometimes a style rule just gets trumped by a rule from the ma...

How to Target IE7 IE8 with CSS valid code.?

I want to Target with CSS valid code. to IE7 and IE8, Please Give me some Information about this Issue and CSS code should be W3C Valid. IE8 is here. Some time we fix for IE7 but not work in IE8. ...

Locating tag by its text using css

How would you get the following tag using CSS? <p>You can only use the text inside the tag</p> As in xpath I'd use the following: //p[contains(text(), "inside the tag") PS: I can't close the xpath, it tries to auto complete with code... :S ...

How to find ID of the closest upper element with specific class name?

HTML Code: <div id="1" class="master"></div> <div id="2" class="slave"></div> <div id="3" class="slave"></div> <div id="4" class="master"></div> <div id="5" class="slave"></div> <div id="6" class="slave"></div> let's say, we use $('div').click() to make these DIV elements clickable: $('div').click(function() { var el = $(this); ...

What is CSS Selector @page?

I'm creating an epub file and am trying to understand an example css for an ebook: @page { margin-top: 0.8em; margin-bottom: 0.8em;} What's the @page selector? I can't find it in my books or Google. Thanks, Larry ...