3 ms·
Ask HN: Is it dumb to line up your code eg. semi-colons
At this time this is the worst for me with CSS, I keep ligning up my colons so they're all aligned (per group eg. a class)
I also do this with arrays/general assignments (aligning equal signs) I think I understand this doesn't matter for compiling, regarding minifying these spaces would be a waste.
I do feel the "slow-ness" when I'm sitting there banging away at the space key. I use 2-character spacing instead of 4.
I don't know it looks good to me... I'm just wondering if I should get rid of the habit.
Example:
CSS
.square {
position : relative;
width : 300px;
height : 150px;
display : flex;
align-items : center;
justify-content : center;
background-color : white;
}
- cpburns2009 10y agoWhile it seems nice and neat at first, it can easily become messy because inevitably you'll end up with a long property name that messes up the style. Say you want to round the top borders. You either end up with an additional 7 space wide alignment: .square { position : relative; width : 300px; height : 150px; display : flex; align-items : center; justify-content : center; background-color : white; border-top-left-radius : 10px; border-top-right-radius : 10px; } Or you end up with an inconsistent alignment: .square { position : relative; width : 300px; height : 150px; display : flex; align-items : center; justify-content : center; background-color : white; border-top-left-radius : 10px; border-top-right-radius : 10px; } If you go for inconsistent alignment, where is the cutoff? I eventually broke myself of the habit trying to align the right side. It's too much effort to manage for something trivial.
- ge96 10y agoYeah that's the problem, you add a longer property and then oh no, gotta go back and bang in the space key some more. Oh man... Even variable declarations and JSON? I don't know... The problem too is when you work on other people's code spaced differently and no alignment at all. Damn.