💡 CSS massive upgrade: light-dark() now supports images! We've been using light-dark() for colors for a while, but the spec just got a major upgrade: It now supports images. 🖼️ 🛑 The "Old" Way (Boilerplate Alert) Until now, swapping a background pattern or a logo meant jumping back and forth between :root and @media (prefers-color-scheme: dark) :root { --bg: url(light-pattern.png); } @media (prefers-color-scheme: dark) { :root { --bg: url(dark-pattern.png); } } .hero { background-image: var(--bg); } ✨ The "Modern" Way (Clean & Concise) With the new update, you can handle the logic right where the property is defined. It's cleaner, more readable, and easier to maintain. .hero { color-scheme: dark; background-image: light-dark(url(light-pattern.png), url(dark-pattern.png)); } 🛠️ How to experiment safely today Since this is a fresh update, you'll want to use feature detection. Because linear-gradient() is technically an <image>, you can use it to test for support: @supports (background-image: light-dark(linear-gradient(white, white), linear-gradient(black, black))) { /* Modern image-switching logic here */ } Are you still using traditional media queries for theme switching, or have you fully embraced the light-dark() life yet? 👇 Read more: Article by Bramus https://lnkd.in/gsE2KrdA #CSS #CSSTricks #CSSHacks #Frontend #WebDevelopment #CodingTips #WebDev #itsmacr8
CSS light-dark() now supports images
More Relevant Posts
-
🛑 Stop wasting time on outdated CSS hacks. The future of frontend is here with 3 massive updates that promise to simplify everything: 1️⃣ Native IF-ELSE Logic: Write direct, conditional styling without nesting media queries. Clean responsive code! 2️⃣ CORNER-SHAPE: Complex clip-paths? A thing of the past. Create unique shapes natively. 3️⃣ @SCOPE: Component-level scoping made easy. Modular design without selector collisions. Check out the visual breakdown below for a look at where we’re headed. 🚀 ⚠️ BUT HOLD ON... A WORD OF PRAGMATISM! Before refactoring your whole project: Browser Compatibility is Key: These are bleeding-edge features. Always check current support and determine if your user base is ready, or if you'll be drowning in polyfills. Weigh Code Complexity: Sometimes, "new" isn't "better." If the new method introduces unnecessary overhead, stick with classic, predictable, and widely-supported CSS. Classic code still works! Use the right tool for the job. Which of these features are you most excited to implement strategically? Let's discuss browser-support strategies in the comments! 👇 #CSSUpdates #FrontendDevelopment #WebDesign #BrowserSupport #CodeBetter #DevLife #WebDevTips
To view or add a comment, sign in
-
-
Many developers still write CSS selector lists the old, repetitive way, leading to bloated stylesheets and increased file sizes. This approach often makes your CSS harder to read and maintain, especially as projects scale and more elements need similar styling. Ignoring modern CSS features like :is() means you're missing out on cleaner, more efficient code. This isn't just about aesthetics; verbose CSS can directly impact performance by increasing parse times and network requests, even if minified. Imagine trying to update a specific style across dozens of these scattered, redundant selectors – it becomes a tedious and error-prone nightmare. Adopting :is() allows you to group common selectors into a single, concise rule, making your CSS significantly more readable and easier to manage. It's a small change with a big impact on the overall health of your codebase. Are you still writing it the old way? #css #webdevelopment #frontend #csshacks #codingtips
To view or add a comment, sign in
-
-
It occurs to me that a lot of the arguments in favour of Tailwind boil down to people misusing CSS. That's not to say there aren't plenty of valid use-cases, but using any tool should be a decision supported by solid fundamentals, and it shouldn't be an escape hatch to get out of bad code/markup. If you find yourself naming a class "container-inner-left-final-v2" then there are much larger issues at play than CSS being clunky. Here are some questions you can ask yourself to determine whether or not a class makes sense or if the current styles would benefit from a refactor: - Are the HTML tags in use semantically appropriate for the places in which they are being used? - Do you have elements on screen whose sole purpose is to enable a particular style, look, or effect (i.e. they do not directly hold content or contribute to the structure of the layout)? Are there any modern CSS features which have made this pattern unnecessary? Is that style, look, or effect necessary to the user experience? - Are you leveraging reusable styles and utility classes which do more than just change a single attribute on a particular element? Do you have a consistent design language for your app, site, or brand? Does the specific element you're creating the style for justify an exception to existing styles? - Are you correctly leveraging scope, variables, and specificity so that you avoid escape hatches like repetition or `!important`? - Are your styles organized such that you can easily find where they are declared? Are you certain that there are no unintentional clashes or style bleed? CSS, as a fundamentally-important part of any web-based application, is something that should be considered on a large scale before any code is written at all. It should be architected just like everything else. Planning an extensible and scalable structure and enforcing that structure will go a long way towards reducing technical debt and code smell.
To view or add a comment, sign in
-
Modern CSS is having a moment — and it’s making UI code dramatically more maintainable. Three features I keep reaching for: - **Container Queries** Components can respond to the size of their *container*, not just the viewport. That means truly reusable UI that adapts wherever it’s placed. - **Cascade Layers** A cleaner way to control style precedence without fighting specificity wars. Great for organizing resets, design tokens, components, and utilities. - **`:has()` selector** The long-awaited “parent selector” unlocks patterns that used to need JavaScript. Think smarter form validation states, conditional layouts, and richer interactions. Why this matters: Modern CSS is shifting from “workarounds and overrides” to **intentional, scalable styling architecture**. We’re finally getting tools that make components more portable, styles more predictable, and codebases easier to evolve. If you haven’t revisited CSS lately, now’s a good time. **Which modern CSS feature has had the biggest impact on your workflow?** #CSS #WebDevelopment #Frontend #UIDesign #ResponsiveDesign #SoftwareEngineering Summary: Wrote a concise LinkedIn post highlighting container queries, cascade layers, and `:has()` with a professional, engaging tone. #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
If your CSS needs `!important`… you already lost. --- Took me a few years (and a lot of broken layouts) to understand this. Early in my career, I used to write CSS like this: .header .title span div { font-size: 18px; } It worked. I shipped features. Nobody complained. But after a few months on the same project… • Small changes started breaking other pages • I had to trace styles across multiple files • I was honestly scared to touch old code And yeah… `!important` became my best friend 😄 --- That’s when I realised: The problem wasn’t CSS. It was how I was structuring it. I was writing styles based on HTML structure instead of thinking in components. --- Once I simplified it, things changed: .header {} .header__title {} .header__title { font-size: 18px; } Nothing fancy. But way easier to manage. --- Now: • I can move things without breaking UI • Code is easier for others to understand • Debugging takes minutes, not hours --- Now coming to Tailwind 👇 I actually like Tailwind for a lot of cases. ✔ Fast to build UI ✔ Consistent spacing & design system ✔ No naming headache But even with Tailwind… 👉 You still need structure 👉 You still need component thinking Otherwise you end up with chaos… just in a different form. --- One small rule I follow even today: If my selector (or class list) looks like a paragraph… I know I messed up. --- CSS isn’t hard. Bad structure is. --- Curious — what do you prefer? BEM, Tailwind, or something else? 😄 --- #frontend #webdevelopment #css #tailwindcss #ui
To view or add a comment, sign in
-
-
Most developers think CSS specificity is simple… until styles start breaking in real projects. Let’s break it down 👇 Specificity is calculated like a score: • * → 0 • div, p, h1, a → 1 • .class → 10 • #id → 100 • inline styles → 1000 • !important → 10000 🚨 👉 The rule is simple: higher score wins Example: .card .title → 10 + 10 = 20 #header .title → 100 + 10 = 110 So even if .card .title comes later in your CSS… it still loses. — Now here’s where things start going wrong in real-world codebases 👇 When styles don’t apply, most developers react by increasing specificity: #app .container .card .title span At this point, you're no longer styling… you’re fighting a specificity war. And the end result? • Hard-to-maintain CSS • Unexpected overrides • Overuse of !important • Fear of touching existing styles — This is where BEM (Block Element Modifier) comes in. BEM avoids the problem entirely by keeping specificity flat: ✔️ .card → 10 ✔️ .card__title → 10 ✔️ .card--active → 10 • No nesting • No escalation • No surprises Everything stays predictable. — The trade-off? BEM gives you slightly longer class names… but in return, you get: • Scalable CSS • Easy overrides • No specificity conflicts • Cleaner architecture — The real insight: CSS specificity isn’t the problem… lack of control over it is. BEM works not because it’s fancy — but because it enforces discipline. — If your CSS keeps breaking as your project grows, it’s probably not your styles… …it’s your specificity strategy. What’s your approach — BEM or utility-first like Tailwind? #CSS #FrontendDevelopment #WebDevelopment #BEM #CleanCode #SoftwareEngineering
To view or add a comment, sign in
-
Day 5 of My Web devoplepment journey (CSS) Today, I learned one of the most important concepts in CSS — the Box Model 📦 🔹 What I learned today: • Understanding the CSS Box Model • Content – actual text or element inside the box • Padding – space between content and border • Border – boundary around the element • Margin – space outside the border • Concept of Box Sizing (content-box vs border-box) 📌 Key Insight: Every element in a web page is a box! Mastering the box model helps in controlling layout, spacing, and alignment effectively. Step by step, getting better at designing clean and responsive layouts 🚀 #Day2 #CSS #WebDevelopment #Frontend #BoxModel #CodingJourney #LearningDaily #TechSkills #SoftwareEngineer
To view or add a comment, sign in
-
-
Ever seen what happens when CSS disappears? 👀 I tried a small experiment — took a familiar product and “removed the CSS.” Suddenly, everything looked raw… unpolished… but still functional. And that’s exactly how the web works too 👇 💡 There are different ways we add “style” to our applications: • Inline CSS → Quick fixes, but messy • Internal CSS → Works for small setups • External CSS → Clean, scalable, production-ready • @import → Modular, but slightly slower Strip all of that away, and you’re left with pure HTML — just structure… no beauty. ⚡ It made me realize: Even in development (and maybe life), we spend so much time on styling… but the real strength lies in the structure underneath. 👉 Because no matter how it looks, if the core is solid — it still works. #WebDevelopment #Frontend #CSS #Programming #Developers #Learning #TechThoughts
To view or add a comment, sign in
-
-
🎨 CSS Gradients CSS gradients produce smooth transitions between two or more colors. Commonly used for backgrounds, masks, borders, and overlays without additional image assets. ✅ Linear gradients ✅ Radial gradients ✅ Conic gradients ✅ Repeating gradients ✅ Blending & masks Save & share with your team! Follow Rahul Choudhary for more. Credit :: TheDevSpace w3schools.com, and JavaScript Mastery for more tips, tutorials, and cheat sheets on web development. Let's stay connected! 🚀 #css #gradients #design #ui
To view or add a comment, sign in
-
🚀 CSS is evolving — are you keeping up? What used to take extra code and hacks… is now simpler, cleaner, and more powerful. ✨ Modern CSS brings: • Better readability with nesting • Smarter responsive design with container queries • Improved viewport units (dvw, dvh) • Cleaner transforms and layout control Small changes. Big impact. ⚡ If you're still writing CSS the “old way”… you’re probably doing extra work. 👉 Time to upgrade your workflow. #CSS #WebDevelopment #Frontend #UIUX #WebDesign #Developers #Coding #TechTips #FrontendDevelopment #ModernCSS
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development