css-selectors

CSS selector only works if <tag>has contents</tag>

I'd like to assign a style to a HTML element - but only in the event that the tag has some contents set. Is this possible using pure CSS? Ideally I would like to avoid JS or server-side changes to the structure of the HTML itself. ...

The CSS selector for an element that its id is in the "foo:bar" form

When using the JSF Web application framework, ID of the elements inside a form can be automatically generated by the framework and when a component resides in a form that its ID is form1, the framework automatically generates an ID in the form of form1:foo for that element. While this can be turned off, I was wondering if it's possible t...

CSS how to reduce style definition?

I have a css style definition like the following: input[type=email], input[type=tel], input[type=url], input[type=text], input[type=password], input[type=file], textarea { ... } can that be reduced to something shorter? Note: I don't want to style to apply to e.g. input[type=checkbox], input[type=radio] or input[type=image]. ...

CSS inheriting oddities

I run into this a lot and it's fairly annoying. Does anyone know about this: #content h5 { color:red; } #next h5 { color:blue; } When the markup looks like this: <div id="content> <h5>RED</h5> <div id="next"> <h5>BLUE</h5> </div> </div> The blue h5 will actually appear red, what gives?! ...

Is it inefficient to specify default rules to CSS?

As an example, imagine I have a table. The standard alignment behaviour (not sure if this is html specification or just the browsers I use?) seems to be to left align the body elements and center align the head elements. So if I wanted everything left aligned, is it less efficient to write #MyTable td { text-align: left; } than t...

jQuery - select one of the two classes

Hi, I have a table row elements: ... <tr index="1000" class="class1 classHighlightRed"> ... ... <tr index="1000" class="class1 classHighlightYellow"> ... I would like to check the value of the second class against some constants. E.g. If (2nd class == "classHighlightRed") Then { doSomeWork; } At the moment...

CSS hierarchy hover in wordpress

I'm designing a wordpress theme for general use, all text links have a border-bottom applied on the hover state. When an image is placed into the post, it inherits this state, which I obviously do not want. This only occurs when an unaligned image is placed in the post. Aligned right, left & centered images are placed in a div, unaligne...

CSS form[action] not working with Query Strings

Hi all having a few problems with my CSS I am trying to highlight a link on the navigation based on the page the user is on. I have this style which works as I would like it to do, but when I pass a query-string into pcisHPprofile.aspx the CSS is not working. Does anyone know how i can get this style to work with query-strings? body ...

How do I add two :before elements?

I try to make web site with minimal HTML markup for presentation. Having the following HTML tag: <div class="title">I'm a title!</div> I need to add two elements before it using CSS, 1 for background and 1 for shadow. Something like: .title { display: block; position: relative; } .title:before { display: block; backgr...

What does ">" means in css rules ?

For example: What does div > p.some_class { ... } selects ? ...

CSS: Not overwrite but reset to "normal"

Hi guys I'm working on a website, and I stumbled on a issue I've been thinking about some time now. Somewhere in the CSS-file I defined "Left: 12px" but afterwards some class'es overlap. I want to set "right: 25px" on the same object. But then I have to eliminate the "left"... If this was a background, I could set it to "none", and th...

Can I override a #id ul li behaviour with a class definition

I have an area that is identified by a #id and there is a CSS like: #id ul li { margin:0; } can I, for a specific UL in that area, override the margin-setting? I understand that #id creates very high priority in evaluating the formatting. I have tried: .myclass ul li { margin-left: 20px; } and #id ul.myclass { as well a...

The difference between the child and the decendent selector

These appear to do the same things. I've never been sure what the difference is. <style> #a > b > i{ color: blue; } #b b i{ color: red; } </style> <div id="a"> <b><i>text</i></b> </div> <div id="b"> <b><i>text</i></b> </div> ...

What does .class-name mean as a CSS selector?

So if I have a CSS class named "class-name", what does the following mean? .class-name { margin: 0; } And why, if I had the following HTML <div id="some-id"> <ul> <li class="class-name"> ... would the selector #some-id .class-name ul li not exist? ...

Why isn't my !important attribute working in Google Chrome?

I have two CSS files in my web app: reset.css and screen.css. They appear in that order in the html (reset then screen). In the reset.css, the following style definition occurs: html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img...

How can I get a div to appear when a textarea is in focus? (both are children of the same form element)

I'm having trouble getting my CSS to work :( HTML <form action="/api/submit/" method="post"> <textarea name="post" rows="2"></textarea> <input type="url" name="url" /> <div> <input type="radio" name="someName" value="someValue" /> </div> <button type="submit">Submit</button> </form> CSS form > input { ...

Help with CSS selectors (jQuery datepicker)

I'm tyring to style the jQuery datepicker. I can't use a jQuery theme as it wrecks the rest of my site. I've got it all working expect for one bit - highlighting the current day. The problem I'm having is that when the datepicker first loads the current day is displayed as follows: <td class="ui-datepicker-days-cell-over ui-datepicke...

jQuery Tabbed Interface CSS Problem

Hello! I'm coding a tabbed interface using jQuery and whilst it all works, functionality wise, there is a problem with the CSS. When a tab is active it's text color is meant to change to white but it doesn't even though it is in the CSS and it only changes on hover. Please look at this code and tell me what I'm doing wrong! Here's the ...

Can a ::before selector be used with a <textarea>?

I'm experimenting with some styles on <textarea>s and I tried doing some stuff with ::before and ::after selectors and I couldn't to anything to get them to work. So the question is: is this possible? I know the CSS surrounding forms is arcane beyond mention but it seems like this should work. ...

What's the proper way to write a CSS selector with a class AND a pseudo class?

Simple Question: what's the proper way to write a CSS selector with a class AND a pseudo class? For example: a.someclass:active { top:1px; } or a:active.someclass { top:1px; } Which is correct? If possible, can you give me a source on this - such as a W3C reference? I tried to find it but alas I could not. ...