?
Solved

W3C Validator does not like this line in stylesheet

Posted on 2011-03-07
2
Medium Priority
?
361 Views
Last Modified: 2012-05-11
Hi!

The W3C validator does not like this line in stylesheet
ul.dropdown li:last-child a{border-right:none;}
It says "Unknown pseudo-element or pseudo-class :last-child"
Any specific code modification would be appreciated.

0
Comment
Question by:TrueBlue
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 30

Assisted Solution

by:LZ1
LZ1 earned 200 total points
ID: 35059923
The pseudo code :last-child is not valid in the CSS 2.1 spec.  If you change to validate in CSS 3 it should pass.

Work around: You can class the last LI in your code and then apply your CSS that way
0
 
LVL 14

Accepted Solution

by:
Designbyonyx earned 300 total points
ID: 35060365
LZ1 is right.  You really need to use a class name, as the :last-child pseudo class is part of CSS3, which is not supported by any current version of IE, and it will be another 2 years beofre IE9 has wide enough market share.

So your code would look like this:

<ul class="dropdown">
  <li><a href="#">Link 1</a></li>
  <li><a href="#">Link 1</a></li>
  <li><a href="#">Link 1</a></li>
  <li class="last"><a href="#">Link 1</a></li>
</ul>

Open in new window


If for whatever reason you can't edit the code of the menu, then you can use javascript... in this example I am using jQuery:

$('ul.dropdown li:last').addClass('last');

Open in new window


And your CSS like this:

ul.dropdown li.last a{ border-right:none; }

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question