Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change list-style-type if it has a hyperlink - without javascript/jQuery [duplicate]

Tags:

css

Possible Duplicate:
Complex CSS selector for parent of active child

I have the following code:

<li>
  <a href="jsfiddle.net">Text</a>
</li>
<li>
  only text
</li>​

I have applied css to li element as:

li {list-style-type: circle;}

I want that the element li on hover should have list-style-type:disc, but only if it has an anchor element inside it. I know its a cakewalk using javascript, but is it possible to achieve this without javascript?

I have tried something like this, but could not achieve it: http://jsfiddle.net/k5SQe/

like image 690
Ankit Avatar asked Oct 23 '22 00:10

Ankit


1 Answers

There's no "parent" selector in CSS. You cannot add a circle style to a <li> element, with the given requirements.

Though, it's possible to add the bullet to the anchor : http://jsfiddle.net/k5SQe/31/

li:hover a {
    display: list-item;
    list-style-type: disc;
}
like image 152
Rob W Avatar answered Oct 27 '22 10:10

Rob W