AllisonC
AllisonC

Reputation: 3099

Period in CSS, does it do anything?

I'm dealing with someone else's code here and have come across something like this:

.selector {
 .background-position : 0px 2px;
}

Does the period on the line background-position do anything or was that their way of commenting the line out? It doesn't seem to have an effect that I know of (using chrome inspector and firefox inspector) but I want to make sure.

Thanks for any insight on this.

Upvotes: 4

Views: 3945

Answers (4)

Chad Ferguson
Chad Ferguson

Reputation: 3091

Period prefixes indicate styles exclusive to IE7 CSS Browser Hacks

Upvotes: 0

Ben Pearson
Ben Pearson

Reputation: 7752

That isn't valid CSS; my guess is it's a comment or a mistake.

I have seen people use characters like _ and * to make sure some properties are only rendered in particular browsers (for example _background-position would be applied in only IE6), but never seen it done with a '.'

Upvotes: 2

rid
rid

Reputation: 63442

I usually use a z to quickly comment stuff out. But in the production CSS, I remove these lines.

It's a "comment". It makes the CSS invalid though and it looks very unprofessional, so it's a good idea to remove it altogether if you don't need it, or at least properly comment it with /* ... */.

Upvotes: 4

Spudley
Spudley

Reputation: 168655

A period there - ie in .background-position - is not valid CSS.

A period is valid in the selector, as you've shown it - ie .selector, in which case it selects elements with class='selector'.

But if I understand the question, you were asking about the dot in .background-position, which as I say is not valid. If you try to add .background-position as a style in Firebug, it won't accept it.

Upvotes: 4

Related Questions