Log in

View Full Version : clarification - space or no space



brentnicholas
09-09-2008, 09:57 PM
Ok, so I'm not a css expert by far, but can get what I need done.

I took a CSS intro class about 2 years ago and the guy said to not leave spaces between the operand(I think that's the right term) and the parameter, it can cause errors....

ex: text-align:left;

However, nearly everywhere I go in reading examples, everyone uses spaces.

ex: text-align: left;

I know this is probably more academic than anything else, but I just thought I'd check and see since there are a number of experts floating around on this forum.

Yeah, I'm one of those nit-picky programmers...

Thanks!
BN

Medyman
09-09-2008, 11:38 PM
I don't think it matters one bit. It's just personal preference. I usually add a space after the colon as it's more readable that way.

What your instructor might have been referring to are inline paramaters. For example:


<table cellspacing="0" cellpadding="0">

In the above case, adding spaces after the "operand" (equals sign) would be inappropriate but might will render probably.

Twey
09-10-2008, 07:28 AM
I concur that it doesn't matter at all whether you use spaces between properties/values or not. It's generally easier to read if you do.

One place where it can matter, though, is between the selector and the opening { of a property block. A space there isn't technically necessary, but omitting it can cause bugs in earlier versions of IE, so leaving it out is bad style.

brentnicholas
09-10-2008, 02:37 PM
One place where it can matter, though, is between the selector and the opening { of a property block. A space there isn't technically necessary, but omitting it can cause bugs in earlier versions of IE, so leaving it out is bad style.

Ah, I bet that's what he was talking about... thanks.