Reputation: 5122
What is the difference between:
border-right: 1px dotted #CCCCCC;
and:
border-right: 1 px dotted #CCCCCC;
Is there any?
Is the second incorrect? Do you need to have the number right next to px
?
Upvotes: 4
Views: 1603
Reputation: 11
I am working wordpress and had a media query not work. It was just ignored completely. Took a frustrating hour to realize this was the issue. I had a space before the px (example: "648 px" instead of "648px").
I would suggest not leaving in a space between even though most of the time it works fine.
Upvotes: 1
Reputation: 19539
From the CSS specification:
The format of a length value (denoted by
<length>
in this specification) is a<number>
(with or without a decimal point) immediately followed by a unit identifier (e.g., px, em, etc.). After a zero length, the unit identifier is optional.
So, immediately after the number should come the unit identifier. It's likely that different browsers will enforce this differently, but when in doubt, go with what's in the spec.
Cheers
Upvotes: 5
Reputation: 2300
border-right: 1px dotted #CCCCCC; is correct
border-right: 1 px dotted #CCCCCC; is incorrect
This is because there are multiple ways to define the length like "1px" or "1" but the problem is when you seperate them by a space like "1 px" css would think the width is "1" and the next classifier is "px". By that I mean in the incorrect example the css thinks "px" is what you are trying to enter instead of "dotted". And so forth for the rest of the code. The problem is though that in the incorrect example you have too many selectors so the code gets confused and won't work.
Upvotes: 2
Reputation: 303253
"The format of a length value (denoted by
<length>
in this specification) is a<number>
(with or without a decimal point) immediately followed by a unit identifier (e.g., px, em, etc.). After a zero length, the unit identifier is optional."
Source: http://www.w3.org/TR/CSS21/syndata.html#length-units
In other words: having a space before the "px" is a syntactical mistake. Have you validated your CSS?
Upvotes: 6