Giter Site home page Giter Site logo

hsl(), hsla() and rect() about code-guide HOT 7 CLOSED

mdo avatar mdo commented on July 19, 2024
hsl(), hsla() and rect()

from code-guide.

Comments (7)

hnrch02 avatar hnrch02 commented on July 19, 2024

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?

from code-guide.

zlatanvasovic avatar zlatanvasovic commented on July 19, 2024

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.

from code-guide.

MaciejLisCK avatar MaciejLisCK commented on July 19, 2024

@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

from code-guide.

zlatanvasovic avatar zlatanvasovic commented on July 19, 2024

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

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

from code-guide.

mdo avatar mdo commented on July 19, 2024

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.

from code-guide.

zlatanvasovic avatar zlatanvasovic commented on July 19, 2024

Thanks.

2014-03-05 17:51 GMT+01:00 Mark Otto [email protected]:

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

from code-guide.

hnrch02 avatar hnrch02 commented on July 19, 2024

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).

from code-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.