css-selectors

Stacking CSS3 Structural pseudo-classes

While practicing different scenarios in which CSS3 pseudo-classes and selectors might come in handy, I ran across something I just can't figure out! Here's the situation. I want to modify the :first-of-type::first-letter of the first non-empty paragraph for a block of text. I'm not sure that pseudo-classes can be stacked though. Here's ...

Help registering an event listener on an element

This is the structure of HTML. I have to add an event listener when user click on div with className "next_button". I try to add an event listener by using prototype. <div id="horizontal_carousel2"> <div class="previous_button"></div> <div class="container" > <ul> <li></li> <li></li> <li></li> <li>...

How do the performance characteristics of jQuery selectors differ from those of CSS selectors?

I came across Google's Page Speed add-on for Firebug yesterday. The page about using efficient CSS selectors said to not use overqualified selectors, i.e. use #foo instead of div#foo. I thought the latter would be faster but Google's saying otherwise, and who am I to go against that? So that got me wondering if the same applied to jQuer...

Is there a more succinct CSS selector expression for this StackOverflow improvement?

I created this user style to make my StackOverflow use much more pleasant. As the screenshots there illustrate, my sidebar contains only the "Ignored Tags" header and input box. I don't care about all of the unanswered tags, nor about all of the tags I've already ignored. Here is the CSS: #sidebar > * { display: none } #sidebar > :nth-c...

Selector and Iterating Through a Table Within a Div

I have been working on this and cannot get this iterator to work. I have the following HTML and am trying to iterate through all rows (except the first row) and extract the values in cells (td) 2 and 3 : <div id="statsId"> <table width="220" cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td widt...

XPath to CSS Selector

I have the following xpath statement in a selenium test: //tbody/tr[td/span[text()='IPODate']]/td[4]/input It gets what I want but my tests are painfully slow in IE6. Anyone know how I would do the same selector as CSS selectors? I think I understand how to do each of these with exception to the text()="IPODate" part. As requested he...

Styling with CSS2 when attr is not set

Styling an element with an attribute set is easy: E[attr]. Is there any way to style an element with CSS2 based on the absence of an attribute, something like this E[!attr]? (JavaScript solution is not an option). For example, there are several class rules followed by id rule: .abc {padding:1em;} .def {padding:2em;} #n a {padding:0;}...

What is the benefit of using the "transparent" value in the CSS background property before a url of a png?

I have often seen stylesheets written where you have something like this: #anyelement { background:transparent url(../img/filename.png) no-repeat left top; } The value in question is the "transparent" value - what is the benefit of using this value? I have never really used it with my own css files and my PNG images still seem to wo...

How do I match a parent who has a specific child?

I want to match a with id "breadCrumb" only if it has a child span id "userName". Match: <div id="breadCrumb" class="nav"> <span id="userName">esac</span> </div> But not match: <div id="breadCrumb" class="nav"> <span id="navtrail">...</span> </div> I want to set #breadCrumb { display: none; }, but I don't want to hide it ...

nokogiri with :after css pseudo selector

I've the following html: <li><a href="/stumbler/millisami/tag/company/" class=""> <span class="right">69</span> company</a> </li> and I want to scrap the text after the span tag, i.e. "company" So, when I tried doc.at_css("span:after") the no method error :after is thrown. How to use pseudo selectors with Nokogiri?? ...

Selecting a column (jQuery)

$('.table tbody td:eq(3)').addClass('col4'); ..works, but only selects the first cell, not all cells in the column. ...

getting a deeply nested css element with jquery

hello. I'm having troubles running an onchange event on a somewhat deeply nested form pulldown. So basically I have a form with an id of maxResultsForm inside a table with an id of listProductsResults inside another table with an id of listProductsSettings... with an id on the select tag of maxResults I've tried the below selector an...

How to extract attribute values using css selectors?

I want to select the values of attributes of an element. For e.g if I have an input element <input type="text" name=myInput value="100"> I can locate it using input[name='myInput'], but how do I get the value of it using a css selector? BTW, I am trying to do this in Selenium using css selectors ...

Why bother with the "L" in the "LVHA" link styles?

Isn't the "a:link" pseudoclass redundant with "a" when put in that order (:link, :visited, :hover, :active)? Why put this: a:link {color: blue;} a:visited {color: purple;} a:hover {color: red;} a:active {color: yellow;} When you could just put this: a {color: blue;} a:visited {color: purple;} a:hover {color: red;} a:active {color: ye...

How to give style to list item only if item has another <ul> inside otherwise style should not apply?

How to give style to list item only if item has another list inside otherwise style should not apply? using css only. See example here http://jsbin.com/udora I want to remove arrows from all other items except "Articles" and "Pitching Past the 7th Inning" I realized it's not possible with css any working jquery solution with demo? ...

a element in nested divs, jquery events not working.

i want to use an event of an anchor element in some nested div's but something is not working in my code. i tried hundreds of variations on that selector but it still does not work. html code: <div class="tabContents"> <div class="thumbArea"> <a href="#"> <img src="foo" alt="baba"/> </a> </div> <div class="imageArea"> ...

CSS selector for table of a particular class in Selenium

Even though I am going to use this CSS selector in Selenium, this should be generic enough. I have a page with table of class "list" & it can occur multiple times. I want to find out each occurrence & how many rows each table has. So for this I could use table[class='list'] & will give me all the tables of that class in the page. In th...

Mootools - selecting a DOM element by its classes

I use MooTools, and I need to find the element which has both classes "a" and "b" (the innermost div in my example below). The HTML structure is: <div class="a"> <div class="otherclass"> <div class="b"></div> </div> </div> In jQuery it's $("div .a .b"), as far as I know. What's the mootools syntax? I've tried $$("div ....

CSS div class selection question

I downloaded a framework and they are using this as a css selector: "#Footer .footerTop" Why not just use: ".footerTop" Are they the same, or selection is different? ...

CSS Selector for label bound to input

Is there a way in CSS to select the label fields which are bound to input fields (via the for attribute) having the required attribute set? Something like -- label:input[required] Currently, I'm adding class=required to labels and inputs for styling. I now have the HTML5 attribute required="required" in the required input fields. Wou...