css-selectors

Selecting all direct children of a <ul> element

Say I have: <ul class="menu"> <li>One</li> <ul class="submenu"> <li>Apple</li> <li>Orange</li> </ul> <li>Two</li> <ul class="submenu"> <li>Pear</li> <li>Banana</li> </ul> </ul> Is there a way to select only the first children of the top level <ul> element (in this case "One" and "Two") with just CSS? ...

CSS Selectors in Javascript with all H tags

Using Prototype JS library, I want to select all child link elements (A tags) regardless of whether their parent is: H1, H2, H3, H4, or H5 (etc) with a simple CSS Selector Rule (as opposed to further JS, like looping etc). So the simple, but long way, to do this is: $('page').select('h1 > a, h2 > a, h3 > a, h4 > a, h5 > a') I guess I...

What does > in CSS mean?

In the IUI css file, they use the following selectors: body > *:not(.toolbar) body > *[selected="true"] What does the >, *:not() and *[] mean? Thanks. ...

What are the priorities among CSS selectors

CSS Question: If two different selectors apply to an element, who wins? I know this shouldn't happen, but I want to tweak a legacy application, and the CSS is getting in the middle. ...

Is there a way to refer to an html element with multiple classes?

I have the following <p class="main yellow">Hello World</p> I would like to write a css element that refers to only elements with main and yellow. Is there a way to do this? Eg. the following doesn't work, but would be what I'm after .main + .yellow { color:green } ...

How to detect mailto links with Hpricot/Nokogiri

I want to match links like <a href="mailto:[email protected]">foo</a>, but this doesn't work only works in Nokogiri: doc/'a[href ^="mailto:"]' What's the right way of doing that? How do I do that with Hpricot? ...

A Regex builder for CSS queries

I've got a problem I need solved using Regex expressions; it involves taking a CSS selector and compiling a regex that matches the string representation of the nodes inside an HTML document. The point is to avoid parsing the HTML as XML and then either making Xpath or DOM queries to apply style attributes. Does anyone know of a project ...

Get parent of a child element that has a certain class

I have a nested menu like this: <ul id="menu"> <li>Home <ul> <li>New</li> <li class="selected">Open</li> <li>Folder</li> </ul> </li> <li>Another menu <ul> <li>submenu item 1</li> <li>submenu item 2</li> <li>submenu item 3</li> ...

What's the difference between these two jQuery selectors?

With this markup: <div id="e"> <div id="f"></div> </div> Does $('#e > #f') return the same as $('#e #f')? ...

CSS a.className:attr properties

I have the following html markup: <span class="content_right_img"> <a href="url" class="pic_link"><img src="lnk.gif" alt="alt" /></a> </span> <p>blah blah blah <a href="url">link text</a> more blah blah blah</p> and the following CSS rules: #mainContent a:link { text-decoration: none; color: black; border-bottom: 2.5px solid #FF0; }...

Is it possible for lxml to work in a case-insensitive manner?

I'm trying to scrape META keywords and description tags from arbitrary websites. I obviusly have no control over said website, so have to take what I'm given. They have a variety of casings for the tag and attributes, which means I need to work case-insensitively. I can't believe that the lxml authors are as stubborn as to insist on full...

CSS selector that applies a style to COLGROUP but only within TBODY (not THEAD)?

I would like to apply a background-color to a COLGROUP, but only within the TBODY of the table. Given a typical calendar table with a structure as the following: <table> <colgroup class="weekdays" span="5"/> <colgroup class="weekend" span="2"/> <thead> <tr> <td/><td/><td/><td/><td/> <!-- I'd like the columns of th...

IE8 focus pseudo class and Sibling Selector

I have some mark up and I am trying to have the "hints for some input" light up when the accosicated text input has focus. I am trying to use the focus pseudo class along with a sibling selector. If i just use one or the other it works just fine. However, when combining them in IE8 it apears as if that style doesn't get updated when you ...

OS-Specific CSS?

In the past, I've seen nearly no difference between CSS in the same browsers on different platforms- pages on Safari on Mac usually look identical to Safari on Windows (and same with FF-Win vs FF-Mac). However, now I'm having an issue where both Mac browsers are pushing some elements off by a pixel compared to their PC counterparts. Is...

CSS selectors: Is there a way to select surrounding elements?

I have a feeling this might involve some sort of advanced selectors, but I could be wrong. I have this HTML to work with: <dt></dt> <dd><input type="hidden" class="hidden"></dd> ...and I need to make the DT and DD tags to be hidden from view. I am able to apply a class on the input tag but not on the others. So how can I apply the "hi...

Css Selector problem

How do I do a css selector that selects a div that has the class of "someButton" AND "current"? .someButton .current { /* select current with the parent div of .someButton, correct? */ Please help me figure this out! ...

CSS Selector Syntax

For this HTML: <div id="idName" class="className"> ... </div> I know this is correct selector syntax: div.className {...} div#idName {...} By mistake I did: #idName.className {...} It seams to work but I don't think it's valid. Can anyone confirm if this is valid? Edit: To clarify, this id will be on many pages and, depending ...

Asserting the background image of a page with selenium

Hey, I have an app in which the user can change the background image of their profile page. Therefore, I wasnt to assert that, when the user changes the image, the image actually changes. I can't for the life of me figure out a css selector or xpath to do the job. This is the HTML I have: <body style="background:#FFFFFF url(/uploads/i...

Why does the :link pseudo selector break expected CSS specificity rules?

To my understanding, the CSS specificity rules indicate that a pseudo selector has the same weight as a tag selector. So a selector like "div p a" would be more specific than "a:link". But as the following test case demonstrates, that does not seem to be the case. Why is the link red? <!DOCTYPE HTML> <html> <head> <title></title> ...

Could it be possible to make css selector affect other elements in the page without javascript?

For example, I want to make two textboxes have the same style when either is focused: <div class="divTxt"> <input type="text" id="a" class="a" /> <input type="text" id="b" class="b" /> </div> and the css would be: .a:focus { background-color:Blue; } .b:focus { background-color:Yellow; } What I need is make a's bac...