Skip to main content

How I Made My Site Look Modern Without Breaking Older Browsers with This CSS Trick

 

How I Made My Site Look Modern Without Breaking Older Browsers with This CSS Trick


How I Made My Site Look Modern Without Breaking Older Browsers with This CSS Trick

My site used to break in older browsers, and I’d spend hours tweaking CSS to patch the holes.

It’s exhausting. You want your site to shine, but older browsers keep throwing issues. Users deserve a website that shines on modern browsers but never breaks on older ones. The CSS @supports rule changed everything for me.

Here’s It in Action

Here is a simple example for CSS @supports rule:

/* Fallback for all browsers */
.card {
display: block;
margin: 1rem;
}
/* Only applied if grid is supported */
@supports (display: grid) {
.card {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 1rem;
}
}

How It Works

The @supports rule checks if a browser understands a CSS property or value. If it does, it applies your shiny modern styles. If not, it sticks to your fallback.

/* Single feature check */
@supports (display: flex) {
/* Flex styles here */
}
/* Multiple features using and */
@supports (display: flex) and (gap: 1rem) {
/* Styles that need both flex and gap */
}
/* Alternative features using or */
@supports (display: flex) or (display: grid) {
/* Styles for either flex or grid */
}
/* Checking for lack of support using not */
@supports not (display: grid) {
/* Fallback styles for browsers without grid */
}

Playing Around With Multiple Properties

Suppose you want to test out multiple CSS properties at once whether they are supported by browsers, here is a simple example on how to do it:

/* Single feature check */
@supports (display: flex) {
/* Flex styles here */
}
/* Multiple features using and */
@supports (display: flex) and (gap: 1rem) {
/* Styles that need both flex and gap */
}
/* Alternative features using or */
@supports (display: flex) or (display: grid) {
/* Styles for either flex or grid */
}
/* Checking for lack of support using not */
@supports not (display: grid) {
/* Fallback styles for browsers without grid */
}

Here Are Some Pro Tips To Remember

  • Always choose fallback styles that work everywhere.
  • CSS @supports rule should be used to improve user experience when there are chances modern CSS features can break in older browsers.
  • To make things simple, always prefer testing the CSS properties individually.
  • Make sure the fallback code is not very complex and is maintainable.

Final Takeaway

Today we had a look at a cool CSS feature that allows you to build modern beautiful websites with the support for older browsers.

Thank you. Let’s meet again with another cool adventure of CSS.

Thank you for being a part of the community


Comments

Popular posts from this blog

Exploring Google’s New Gemini CLI: The Ultimate Open-Source Dev Tool

  Google quietly released a local AI agent that builds apps, debugs code, parses your repo, and fetches real-time data, right inside your terminal. And it’s completely free. This year, the most revolutionary developer tools I’ve used didn’t come with a splashy launch or billion-dollar hype. It came as a simple CLI: Gemini CLI, a terminal-based AI agent built on top of Google’s Gemini 2.5 Pro model . At first glance, it looks like a lightweight alternative to Claude Code. But after just 10 minutes of use, it became clear: this isn’t just a convenient utility. It’s a powerful local AI development assistant that can analyze, automate, and accelerate almost every part of your software workflow. And best of all? It’s fully open-source under the Apache 2.0 license It gives you up to 1,000 free requests per day It integrates with your local filesystem, IDE, and the web And it runs entirely in your terminal , no browser needed In this guide, I’ll show you what Gemini CLI is, how it works...

Sharpen Your Front-End Skills: Quick HTML, CSS & React Interview Challenges

  The source of this image is Chat GPT based on writing! Are you preparing for front-end developer interviews and looking for practical, hands-on ways to improve your HTML, CSS, and React skills? Whether you’re a beginner aiming to build confidence or an experienced developer brushing up on UI skills, small, targeted challenges can make a huge difference. In this article, I’ll walk you through some of the best free and low-cost resources that offer real-world front-end tasks — perfect for interview prep, portfolio building, and daily practice. 1. Frontend Mentor frontendmentor.io Frontend Mentor is one of the most popular platforms for hands-on HTML, CSS, and JavaScript challenges. You get beautifully designed templates (in Figma or image formats) and are asked to bring them to life using clean code. The platform offers difficulty levels ranging from newbie to expert, and it’s perfect for practicing responsiveness and semantic HTML. Bonus : You can even filter for React-based ...

Difference Between Three.js and Babylon.js: What Actually Should You Choose?

You don’t have to be just a graphic designer to create interactive designs. You can be a coder and still create visually appealing and eye-catching games. All thanks to JavaScript. The first cross-browser JavaScript library–three.js–that can create 3D computer graphics was first released on 24 April 2010 by Ricardo Cabello. He first wrote the code in ActionScript language, which was then used by Adobe Flash. But then in 2009, he ported the code to JavaScript. Previously, people used WebGL. But the problem was its limitation: it can create only simple pointers and lines. Ricardo, instead of abandoning WebGL as something that is futile, used it to his own advantage. He built three.js on top of WebGL. This renders three.js to create 3D graphics in the browser. Even a 3D scene can be created easily using Canvas and WebGL now. But then in 2013, Babylon.js was created. But why? Why did its creators, Microsoft and David Catuhe, make something that another JavaScript library–three.js –was alre...