<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/defensive-css-tmz6xi81r" -->

---
title: Defensive CSS | daily.dev
description: Defensive CSS is a collection of snippets that can help you in writing CSS that is protected. Oftentimes, we wish that there was a way to avoid a certain CSS...
canonical: https://daily.dev/posts/defensive-css-tmz6xi81r
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Defensive CSS | daily.dev
og:description: Defensive CSS is a collection of snippets that can help you in writing CSS that is protected. Oftentimes, we wish that there was a way to avoid a certain CSS...
og:url: https://daily.dev/posts/defensive-css-tmz6xi81r
og:image: https://api.daily.dev/og/posts/tMz6xi81R.png
og:image:alt: Defensive CSS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Defensive CSS

**[Hacker News](https://daily.dev/sources/hn)** · 11 min read · 156 upvotes · 8 comments

## Summary

Defensive CSS is a collection of snippets that can help you in writing CSS that is protected. Oftentimes, we wish that there was a way to avoid a certain CSS issue or behaviors from happening. This is built upon an article I wrote a while back called “The just in case mindset”

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <http://ishadeed.com/article/defensive-css/>

## Community discussion

Top comments from developers on daily.dev.

**@jindradev** · 3 upvotes

> This should be the top post!

**@prism\_dan** · 2 upvotes

> One of the best articles I've seen on overcoming common layout pitfalls in modern CSS.
>
>
> I'm a big fan of encouraging a more proactive approach to writing CSS. Really well written article!

**@heyshubhi** · 0 upvotes

> Interesting article !!

**@monsieurwize** · 0 upvotes

> Very interesting !!

**@ghost** · 0 upvotes

> Some really important and useful CSS tips.

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#css](https://daily.dev/tags/css)

[View this post on daily.dev](https://daily.dev/posts/defensive-css-tmz6xi81r)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Defensive CSS","url":"https://daily.dev/posts/defensive-css-tmz6xi81r","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/defensive-css-tmz6xi81r"},"datePublished":"2021-12-10T13:48:12.485Z","dateModified":"2021-12-10T13:48:12.485Z","description":"Defensive CSS is a collection of snippets that can help you in writing CSS that is protected. Oftentimes, we wish that there was a way to avoid a certain CSS...","image":"https://ishadeed.com/assets/defensive-css/twitter-card.jpg","thumbnailUrl":"https://ishadeed.com/assets/defensive-css/twitter-card.jpg","isAccessibleForFree":true,"articleSection":"Hacker News","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Hacker News","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/hn","url":"https://daily.dev/sources/hn"},"commentCount":8,"discussionUrl":"https://daily.dev/posts/defensive-css-tmz6xi81r","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":156},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":8}],"keywords":"css","timeRequired":"PT11M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Hacker News","item":"https://daily.dev/sources/hn"},{"@type":"ListItem","position":3,"name":"Defensive CSS"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/defensive-css-tmz6xi81r","comment":[{"@type":"Comment","text":"This should be the top post!","datePublished":"2021-12-10T15:28:57.059Z","url":"https://daily.dev/posts/tMz6xi81R#c-pXKNRv_PS","author":{"@type":"Person","name":"Jindra Vysocký","url":"https://daily.dev/jindradev","image":"https://avatars.githubusercontent.com/u/32195723?v=4"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3}},{"@type":"Comment","text":"One of the best articles I’ve seen on overcoming common layout pitfalls in modern CSS.\nI’m a big fan of encouraging a more proactive approach to writing CSS. Really well written article!","datePublished":"2021-12-14T12:47:33.753Z","url":"https://daily.dev/posts/tMz6xi81R#c-RVtXdTgQI","author":{"@type":"Person","name":"Dan","url":"https://daily.dev/prism_dan","image":"https://media.daily.dev/image/upload/f_auto/v1629022763/avatars/QiOXDSTwq"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2}},{"@type":"Comment","text":"Interesting article !!","datePublished":"2022-07-12T13:30:26.303Z","url":"https://daily.dev/posts/tMz6xi81R#c-wVzLzA1vs","author":{"@type":"Person","name":"Shubhangi","url":"https://daily.dev/heyshubhi","image":"https://avatars.githubusercontent.com/u/70970530?v=4"}},{"@type":"Comment","text":"Very interesting !!","datePublished":"2022-07-07T08:15:51.088Z","url":"https://daily.dev/posts/tMz6xi81R#c-TDZtUbcEF","author":{"@type":"Person","name":"MrWize","url":"https://daily.dev/monsieurwize","image":"https://avatars.githubusercontent.com/u/10169101?v=4"}},{"@type":"Comment","text":"Some really important and useful CSS tips.","datePublished":"2021-12-14T07:41:51.047Z","url":"https://daily.dev/posts/tMz6xi81R#c-Kv627o4GZ","author":{"@type":"Person","name":"Deleted user","url":"https://daily.dev/ghost","image":"https://media.daily.dev/image/upload/s--hNIUzLiO--/f_auto/v1705327420/public/ghost_vlftth"}}]}
```

