Live data from Hacker News

Defensive CSS

defensivecss.dev

11–20 of 73 posts

Re: Defensive CSS

#11
Most of these are pure common sense if you are apt with CSS.

However, one problem mentioned here is vendor prefix grouping. I've never experienced this problem or seen a grouped prefix ignored by any browser. Autoprefixer doesn't even ungroup prefix rules. I even ran a grouped prefix through W3C validator and came away validated, though the article mentions it's not W3C compliant.

Re: Defensive CSS

#12
post #10

Wow this is great. I could have really used some of these examples a few days ago. CSS grid combined with media queries feels like cheating to me. Am I missing something big here, or is this all safe to use in 2022?

Media queries have been safe for over a decade. If you feel uneasy with grids and/or still want to support ancient Internet Explorer versions just use flexbox instead.

Re: Defensive CSS

#13
post #10

Wow this is great. I could have really used some of these examples a few days ago. CSS grid combined with media queries feels like cheating to me. Am I missing something big here, or is this all safe to use in 2022?

CSS Grid is that amazing. I hadn't looked into it much for a while because I had already adopted flexbox, but grid is so much better for most scenarios I encounter.

CSS Grid + CSS Variables really take CSS to another level.

Re: Defensive CSS

#15

Most of these are pure common sense if you are apt with CSS. However, one problem mentioned here is vendor prefix grouping. I've never experienced this problem or seen a grouped prefix ignored by any browser. Autoprefixer doesn't even ungroup prefix rules. I even ran a grouped prefix through W3C validator and came away validated, though the article mentions it's not W3C compliant.

Input placeholder vendor prefixes had to be ungrouped last time I checked. Wouldn’t work when together is a couple browsers but I forget which.

Re: Defensive CSS

#16
I constantly struggle with CSS grids when compared to, say, just using Bootstrap. I know Bootstrap comes with a lot of baggage, but the syntactic sugar is just so useful.

Re: Defensive CSS

#18
post #10

Wow this is great. I could have really used some of these examples a few days ago. CSS grid combined with media queries feels like cheating to me. Am I missing something big here, or is this all safe to use in 2022?

"Am I missing something big here, or is this all safe to use in 2022?"

CSS Grid has been safe for use for a few years now (if you're supporting modern browsers).

https://caniuse.com/mdn-css_properties_display_grid

The problem is that popular frameworks like Bootstrap and Bulma still don't support CSS Grid (they use flexbox only for layout).

It's ironic that developers have rightly complained how cumbersome CSS layout has been in the past. Now we have CSS Grid - and yet developers still aren't using it.

Re: Defensive CSS

#19
It's crazy that there's so much extra cruft when it comes to crafting web interfaces when a CLI is most often the most powerful and easiest way to get a job done. Am I just taking crazy pills?

Re: Defensive CSS

#20
CSS3 got approved in 2006 and now we are at the point where we have to treat the language like it's fighting against us. Quality work the consortium has done in the past 15 years, eh?
Post reply on HN