DelphiFAQ Home Search:

FireFox error "Selector expected. Ruleset ignored due to bad selector"

 

comments24 comments. Current rating: 4 stars (5 votes). Leave comments and/ or rate it.

Question:

The javascript-console of FireFox gives me these errors:

Error: Selector expected. Ruleset ignored due to bad selector.

followed by

Error: Unexpected end of file while searching for closing } of invalid rule set.

Do you have any ideas on what this means and how to resolve it?

Answer:

Review your .CSS style sheet file. You probably have HTML comments in there, similar to what people put in Javascript sections. Remove those comments as shown below.

// this will cause an error in Firefox:

    <style>
    <!--
       .styling { blah... }
    //-->
    </style>


// this is ok:

    <style>
       .styling { blah... }
    </style>

Content-type: text/html

Comments:

You are on page 1 of 2, other pages: [1] 2
2006-11-14, 09:32:06
anonymous from United States  
Where's the .CSS style sheet file located?
2007-01-28, 03:55:42
anonymous from United Kingdom  
I get that warning, but dont have any //-> in my style sheet ( http://www.bandsman..style.css)
2007-01-28, 09:27:06   (updated: 2007-01-28, 09:27:22)
Peter (Admin) from United States  
To anonymous in United Kingdom:

I looked at your CSS file. If it is an external .css file, you should not include the <style> and </style> lines.
2007-02-06, 09:00:08
anonymous from United States  
Hey that worked. Thanks.
2007-07-17, 22:46:56
anonymous  
rating
When you are put an semicolon after the } in the styles(like this

.stylename{
width:10%
};

) at that time also this error will come. Just remove the semicolon then it will works

use this(
.stylename{
width:10%
}

)
2007-09-20, 15:43:52   (updated: 2007-09-20, 15:44:42)
anonymous from Porto Alegre, Brazil  
You may also have something like this in your CSS:

.whatever, {
...
}

The extra comma shouldn't be there, so just remove it:

.whatever {
...
}
2007-09-21, 12:41:08
anonymous from United States  
I actually got this error because I named one of my classes starting with a number:

<style type='text/css' >
.100Percent
{
    width: 100%;
}
</style>

When I changed it to the following the error went away:

<style type='text/css' >
.OneHundredPercent
{
    width: 100%;
}
</style>
2008-06-03, 20:02:14
anonymous from United States  
no html tags in an external, right, and check to make sure all the files are in the same directory.... sounds easy nuff, but a common error. least for me...
2008-12-17, 14:27:08
anonymous from United Kingdom  
When I changed it to the following the error went away:

<style type='text/css' >
.OneHundredPercent

that helped me out thanks I was flummoxed for a while ;o)
2009-07-30, 16:33:14
tel@telgo.com from Reston, United States  
rating
I found the error in

BODY, P, {font-family: verdana, arial, sans-serif;
font-size: 12pt; color: #000000; text-align: left;
}

It was the extra comma after P, due to the fact that I deleted another specifier without removing the comma too.
2009-08-16, 07:06:39   (updated: 2009-08-16, 07:10:39)
anonymous  
(I actually got this error because I named one of my classes starting with a number)



This is helpful for me too ))! Thanks
2009-09-28, 21:29:56
anonymous from Canada  
Removing all HTML tags in my CSS file worked for me! Thanks so much!
2009-11-12, 16:41:23   (updated: 2009-11-12, 16:44:20)
anonymous from Oronoco, United States  
rating
Whoop!.. :-)
Thanks!.. this one has plagued me for years, never bothered to check it out because there never seemed to be anything wrong.
Finally today I googed the string 'Selector expected. Ruleset ignored due to bad selector.' and bingo!, came across this thread!
Hail to the internet!
2009-11-14, 03:01:47   (updated: 2009-11-14, 03:04:55)
anonymous from Australia  
the html code posted is 'altered' by this site... the tags checks out fine...

omg this is getting on my nerves....


<html>
<head>
</head>
<link rel='stylesheet' type='text/css' href='css/logo.css'>
<body bgcolor='#00ff00'>
<div id='logo2'>
<div id='logoupper'>
<div id='logoinside1'>琪利</div>
<div id='logoinside2'>珠江</div>
<div id='logoinside3'>燒臘</div>
</div>
<div id='logolower'>
<div id='logoinside4'><hr class='red1'></div>
<div id='logoinside5'>KAY LEE ROAST MEAT JOINT</div>
<div id='logoinside6'><hr class='red1'></div>
<div id='logoinside7'>125 Upper Paya Lebar Rd S(534838) Tel: 67438778</div>& lt;/div>
</div>
</body>
</html>

W
Warning: Unexpected end of file while searching for ',' or '{'. Ruleset ignored due to bad selector.
Source Filfile: ///C:/Documents%20and%20Settings/Administrator/Desktop/kp/kaylee4/css/logo.css
Line: 1

#logo2 {
color:         #f00;
font-weight:     bold;
text-align:     center;
overflow:     hidden;
}



i dunno what wrong with it...





2009-11-14, 03:25:33
anonymous from Australia  
hell i finally figure out the bloody problem



everythign is fine actually
but if you HTML is saved in unicode ... FF goes nuts...
You are on page 1 of 2, other pages: [1] 2

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: