Kevin Powell

If you are going to write an HSL value in CSS, do you use commas, or spaces? Also, please comment on whether you use units or not... you could do `hsl(10deg, 25%, 50%) or `hsl(10 25 50)` for example... Or do you include percentages, but not degrees?

1 week ago | [YT] | 92



@MaxArt2501

I'll be honest: I still use commas. Even worse, I still use hsla when necessary. Even worse, I still use rgba. Even worse, I still use hex colors...

1 week ago | 13  

@adamstuartclark

I use spaces and a slash if opacity is required. Example; hsl(10 50% 25% / 0.4)

1 week ago | 11  

@MohamIsMe

I do not use hsl because I'm not an animal. (Yes. This is rage bait)

1 week ago | 22  

@randy918

I had no idea I could use spaces! So much simpler than worrying about commas and symbols, thanks Kevin!

1 week ago | 2

@mantevian

I don't remember which I would use. I would prefer using oklch, but I don't remember its css syntax either :D Mostly copy-paste the hex codes from figma into scss variables

1 week ago | 6  

@isaacmaddox2230

I just do hsl(10 25 50). Quicker to write and still works

1 week ago | 3  

@razec95movies

I use commas and units. Having some background in programming, it is deeply encoded to separate and be precise about function inputs. The shorter syntax may be correct, but it just feels wrong.

1 week ago | 1  

@dncdncd

Most often with units, no commas, as it allows for setting an alpha value more easily without renaming the function to hsla

1 week ago | 4  

@StephenMarkTurner

This prompted me to go have a look at the documentation. Wow, lotsa stuff I have never used. Learned what a 'gradian' is. I like the 'turn' for hue angle, easy to think about complements and triads and stuff, plus it's my nickname. 🙂

1 week ago (edited) | 2  

@audiocorps2334

Commas because I'm not letting lazy habits control my syntax. Space is not a good delimiter. Only case otherwise is when I need to copy and paste something that works but didn't know better. Always add units, explicit is notably better than implicit. CSS and programming languages aren't random papers written for school, it's a language that involves collaboration and learning.

1 week ago (edited) | 0

@robwhitaker8534

Not using commas should be illegal

1 week ago | 0

@Rhiogh8462

Whatever chatgpt decides to give me

1 week ago | 1

@nyoing

Spaces and no units. No-brainer, if you ask me.

1 week ago | 0

@KeithGrant

I use unit, especially the deg for the hue, so it’s easy to see at a glance which is the hue. And no commas because I like to think I’m cutting edge 😅

1 week ago | 0  

@AndreGreeff

I've always preferred the so-called "legacy syntax" with commas.. however, maybe the "modern syntax" is actually easier to work with, since you don't need to change `hsl` to `hsla` if you also want to define the "alpha" value. 🤔 hmmm... interesting thought

1 week ago | 0

@moondogdev

i dont choose colors. build off designers guide

1 week ago | 0

@edism

Commas because I'm not a maniac

1 week ago | 0

@AlexTier9165

to be honest all i ever did with rgbas color is guess work but with hsl at least it is a bit more understandable and yes i use spaces as it makes it faster for me to not just write but also easy to use alpha when i need it

1 week ago | 0

@jayzeeques

I use hex colors, oklab, or oklch (with the occasional transparent).

1 week ago | 0

@NicholasZein

There are so many ways of writing the same thing, that I usually write it wrong, then I have to check the documentation, and then I fix my mistake. It's like trying to plug any USB cable that is no the C-type.

1 week ago | 0