Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hsl(), hsla() and rect() #43

Closed
zlatanvasovic opened this issue Mar 5, 2014 · 7 comments
Closed

hsl(), hsla() and rect() #43

zlatanvasovic opened this issue Mar 5, 2014 · 7 comments

Comments

@zlatanvasovic
Copy link
Contributor

If rgb() and rgba() shouldn't have spaces after commas, what about hsl(), hsla() and rect()?

HSL(A) and rect aren't common, but they also shouldn't have the spaces after commas.

@hnrch02
Copy link
Contributor

hnrch02 commented Mar 5, 2014

I'll take the opportunity of this issue and ask why there shouldn't be spaces after commas in rgb() and rgba(). Any particular reason to this contradiction to the "Comma-separated values should include a space after each comma"-rule, except for personal preference?

@zlatanvasovic
Copy link
Contributor Author

It is better for readability.

rgb(0,0,0,0) allows you to read the numbers as fast as possible.

rgb(0, 0, 0, 0) doesn't allow you to focus on the numbers.

@MaciejLisCK
Copy link

@zdroid In your example it is better for readability, but I think this is the only case. Consider following example:

rgba(215,106,180,.9) - in my opinion worse readability

rgba(215, 106, 180, .9); - in my opinion better readability

@zlatanvasovic
Copy link
Contributor Author

I think that rgb(215,106,180,.9) is better.

Edit: that is my opinion, but not everybody writes code on the same way.

@mdo
Copy link
Owner

mdo commented Mar 5, 2014

The guide was updated yesterday to better explain the balance between this and the guideline quoted by @hnrch02.

Comma-separated values should include a space after each comma.

Don't include spaces after commas within rgb() or rgba() colors to differentiate color values from CSS properties that allow multiple values that are already separated by a comma and space. Also, don't prefix values with a leading zero (e.g., .5 instead of 0.5).

These two guidelines go hand-in-hand. The goal is to make rgb(), rgba(), hsl(), and hsla() values appear as a single meta value within your CSS. Multiple values, like those of a box-shadow, should have a space after the comma. Color values, however, shouldn't, as a means of differentiating the two.

Here's a longer example of both these rules combined:

/* With the space after commas within color values. */
.element {
  color: rgba(255, 255, 255, 0.75);
  background-color: rgba(0, 0, 0, 0.5);
  box-shadow: 0 1px 2px rgba(0, 3px, 6px, 0.15), inset 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* Without the space, but with the space between multiple values. */
.element {
  color: rgba(255,255,255,.75);
  background-color: rgba(0,0,0,.5);
  box-shadow: 0 1px 2px rgba(0,3px,6px,.15), inset 0 1px 0 rgba(0,0,0,.5);
}

That's a rather extreme example, and honestly one that doesn't make that much sense color-wise 😆. However, it demonstrates the difference in how the scannability of CSS is affected by too much spacing within property values.

And yes, that section should probably be updated to include these other color options and the rect value.

@zlatanvasovic
Copy link
Contributor Author

Thanks.

2014-03-05 17:51 GMT+01:00 Mark Otto notifications@github.com:

The guide was updated yesterday to better explain the balance between this
and the guideline quoted by @hnrch02 https://github.com/hnrch02.

Comma-separated values should include a space after each comma.

Don't include spaces after commas within rgb() or rgba() colors to
differentiate color values from CSS properties that allow multiple values
that are already separated by a comma and space. Also, don't prefix values
with a leading zero (e.g., .5 instead of 0.5).

These two guidelines go hand-in-hand. The goal is to make rgb(), rgba(),
hsl(), and hsla() values appear as a single meta value within your CSS.
Multiple values, like those of a box-shadow, should have a space after the
comma. Color values, however, shouldn't, as a means of differentiating the
two.

Here's a longer example of both these rules combined:

/* With the space after commas within color values. /.element {
color: rgba(255, 255, 255, 0.75);
background-color: rgba(0, 0, 0, 0.5);
box-shadow: 0 1px 2px rgba(0, 3px, 6px, 0.15), inset 0 1px 0 rgba(0, 0, 0, 0.5);}
/
Without the space, but with the space between multiple values. */.element {
color: rgba(255,255,255,.75);
background-color: rgba(0,0,0,.5);
box-shadow: 0 1px 2px rgba(0,3px,6px,.15), inset 0 1px 0 rgba(0,0,0,.5);}

That's a rather extreme example, and honestly one that doesn't make that
much sense color-wise [image: 😆]. However, it demonstrates the
difference in how the scannability of CSS is affected by too much spacing
within property values.

And yes, that section should probably be updated to include these other
color options and the rect value.


Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-36764592
.

Zlatan Vasović - ZDroid

@hnrch02
Copy link
Contributor

hnrch02 commented Mar 5, 2014

That's a pretty solid point, I still prefer the spaces though, helps for readability IMHO :bowtie: Anyway, when I deal with CSS I write Sass, so I exclusively use rgba(#fff, .5).

@mdo mdo closed this as completed in a6e69b1 Mar 5, 2014
diegoeis pushed a commit to diegoeis/code-guide that referenced this issue Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants