Possible bug in CSS Validator

I have a very long CSS file, which is generated by a PHP program.

Usually, it validates correctly and styles a website under development 
correctly.

But I recently added the following simplified CSS code, which contains a 
syntax error:

..center {
 text-align:center;
 {

You probably notice that the closing brace is incorrect. I didn't notice it.

The result was that most of the styling looked wrong (because it was 
masked out by the open brace).

The first thing I did was to search for the comment characters "//", 
which I often use in CSS by mistake, since they are ubiquitous in two 
other languages I often use, Javascript and PHP. There were none.

Then I ran it through the W3C CSS Validator, and, surprisingly, it passed.

So now I'm wondering, could this be a bug in the CSS Validator, or are 
nested open braces impossible to find because they are used by the 
@media construct, and you don't want to consider CSS a context-sensitive 
language? I can't believe that could be the reason, since active braces 
ought to balance independently of context.

David Spector
Springtime Software

Received on Thursday, 20 February 2025 11:21:17 UTC