tags:

views:

153

answers:

8

Are "CSS Shorthand" not good in team development?

When multiple person work on same project . any person can have different level knowledge of CSS so some people can be confused with shorthand when they need any changes in css.

For example:

Should i avoid this

font: 1em/1.5em bold italic serif

and use this

font-size: 1em;
line-height: 1.5em;
font-weight: bold;
font-style: italic;
font-family: serif 

in team development? and Which shorthands are other CSS shorthand are not good to use for readability and which are good?

+8  A: 

When "writing code", i tend to be fairly verbose. When code such as css/js are pushed to production they can easily be minimized/optimized automatically by a delivery script, giving you the best of both worlds.

Ben Rowe
Code is written for people first, and for computers as a distant second.
Joe Carnahan
+3  A: 

It depends on your team. Personally though, my team likes them, clean, concise and they're not that confusing.

I'd argue that padding: 0 0 5px 0; is more confusing than your font example because you need to know it's top, right, bottom, left...with most shorthand you can read no matter the order and still easily see what's happening.

I'd wager even the average Word user could see your font example and make out what's happening, and that says a lot for clarity.

Nick Craver
I have to disagree here. I bet less than 1 in 100 "average Word users" would have any idea what that example is doing.
echo
I agree with the principle but disagree with the padding thing. It's the same with every box model rule, so it becomes fairly easy to remember. Meanwhile I still find the font rule sequence hard to recall--that's originating, not editing, though. (Well, editing, too.)
D_N
@echo - `font: 1em/1.5em bold italic serif`, it's bold, it's italic, it's a serif font, you don't think they could tell you that much? "wouldn't have any idea" isn't a fair statement I'd say.
Nick Craver
I was referring to the "1em/1.5em" part, which is obviously unclear.
echo
@DN - I agree *once you learn it*, but you do have to learn it in that example. The font is more of glance at it and it's more intuitive was my point, same for something like the background shorthand.
Nick Craver
@echo - Then they'd know what 75% of that rule is doing :) That's far from "no idea"
Nick Craver
well as long as we're being nit-picky about it, i do doubt that any more than 1 in 100 of your average word user would have any idea what a serif is. But I understand your point.
echo
Why is it such an affront to expect people to learn about the technology they're using, especially if it's such a simple thing as CSS shorthand?
deceze
I've never seen the average Word user editing anything close to CSS...
voyager
I agree with @echho "1em/1.5em" is not clear. Why we write like this whay not like this "1em 1.5em". CSS rule is one space needed between pproperty. is this "1em/1.5em" exceptional
metal-gear-solid
@Nick Craver Very true. Just find it less arcane.
D_N
+2  A: 

I tend to think of code as write-once, read-often. So I think short-hands are OK if they're obvious and frequently used, but I think it's best to avoid the odd-ball stuff. I consider myself a competent CSS coder and I must admit that font-size/line-height shorthand is new to me.

echo
It's not precisely new to me, but I've always found it confusing. Which is which? Is it an option? Makes me stop-think, which is no good.
D_N
A: 

It all looks the same from here. If somebody doesn't know how to look up the meaning of the parameters for the short version they're in the wrong role. Also the second takes up more bandwidth. I'd only use the long form if you want to set a couple of the params instead of all of them

John K
+1  A: 

Code for readability (appropriate for the lifetime of the project)

Use compilers, optimisers, and compression for performance

This applies to practically any code, not just CSS

TFD
+3  A: 

If a person is working editing CSS files, he should be able to at least google it if in doubt. After enough times seen the shorthand, it will be second nature to them. Furthermore, they most likely will find it cumbersome to read 5 lines when they could have read 1 (I know I do) to understand what is going on. Being more verbose is not a good thing when trying to get a lot of information.

Readability matters, but its perception changes from person to person. I find the shorthand expression more readable, even if I have to do a google search every now and then to make sure the order is correct. On Python I would never think to not use @decorators or list comprehensions just because one proverbial beginner might find it strange, it makes my code shorter and hence, more readable.

Hand holding doesn't work for developers. Make them suck it up, and learn the language they are being paid to create/read.

voyager
+4  A: 

While evidently unpopular on SO, a couple points in favor of breaking things onto multiple lines in team scenarios:

1) Clarity when using source control. Individual lines changing in source control are often easier to deal with and very clear when reviewing changelogs.

2) With tools like firebug, etc. having the correlation to exact line numbers can be helpful when you are tweaking properties, hunting, saving, reloading vs. one property of many in one line.

Mike Duncan
+1 very true good points. yes i faced firebug problem
metal-gear-solid
in firebug it's easy to switch on/off styles to test with one line for each property see example here http://jsbin.com/iwuci3/3
metal-gear-solid
A: 

The more readable you can make your code, the better. Never assume anyones knowledge.

contactmatt