Monday, June 2, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

CSS Nesting is Here

November 10, 2023
in Front-Tech
Reading Time: 2 mins read
0 0
A A
0
Share on FacebookShare on Twitter



In case you missed it, native support for nesting has been introduced in CSS for all major browsers! Nesting, which is a popular feature in preprocessors like Sass, has been one of the main reasons to continue using preprocessors. However, with native support, it may soon be time to consider dropping a preprocessor altogether.

Nested selectors work in a similar way to Sass. For example, if we have the following markup:

“`html

Child level 1

Child level 2

“`

We can style the nested `

` (a child of the first-level `

`) by simply nesting the selector:

“`css
div {
background: lightblue;
& div {
background: pink;
}
}
“`

We can also use nesting for combinators. In this example using the adjacent sibling combinator, a `

` that directly follows another `

` will have a lavender background. A `

` that is a direct child of a `

` will have a background of lemonchiffon:

“`css
div {
background: lightblue;
& + div {
background: lavender;
}
& > p {
background: lemonchiffon;
}
}
“`

Compound selectors require the use of the `&` operator. In this example, a `

` with a class of `.featured` will have a turquoise background:

“`css
div {
background: lightblue;
&.featured {
background: turquoise;
}
}
“`

Appending the `&` after the selector reverses the context. If a `

` is a child of an element with a class of `.featured`, the `

` will have an orange background:

“`css
div {
.featured & {
background: orange;
}
}
“`

Unlike in Sass, selectors cannot be concatenated in native CSS nesting. However, we can combine selectors, although this increases specificity:

“`css
.featured {
&.featured–large {
font-size: 1.4rem;
}
}
“`

We can also nest media queries, container queries, and other `@`-rules:

“`css
div {
@media (min-width: 600px) {
display: flex;
}
}
“`

Nesting can make our code more readable and maintainable, especially when it comes to media queries. However, it is recommended to avoid nesting more than three levels deep. There may also be some performance concerns, as nested selectors need to be parsed by the browser. It is worth considering the use of a PostCSS polyfill for older browsers that do not support CSS nesting.

Overall, native CSS nesting provides a powerful and convenient way to write more organized and efficient stylesheets.



Source link

Tags: cssfront endNestingweb designweb development
Previous Post

Context in AI Research (CAIR) – Google Research Blog

Next Post

Warren Buffett reportedly traded millions of dollars worth of stocks that Berkshire Hathaway was buying and selling

Related Posts

The essential principles of a good homepage
Front-Tech

The essential principles of a good homepage

June 7, 2024
How to measure and improve user retention
Front-Tech

How to measure and improve user retention

June 6, 2024
Push Animation on Grid Items
Front-Tech

Push Animation on Grid Items

June 5, 2024
How to build a Rails API with rate limiting
Front-Tech

How to build a Rails API with rate limiting

June 4, 2024
Introduction to the B.I.A.S. framework
Front-Tech

Introduction to the B.I.A.S. framework

June 3, 2024
Blue Ridge Ruby is exactly what we need
Front-Tech

Blue Ridge Ruby is exactly what we need

June 3, 2024
Next Post
Warren Buffett reportedly traded millions of dollars worth of stocks that Berkshire Hathaway was buying and selling

Warren Buffett reportedly traded millions of dollars worth of stocks that Berkshire Hathaway was buying and selling

Towards Generative AI for Model Architecture | by David R. Winer | Nov, 2023

Towards Generative AI for Model Architecture | by David R. Winer | Nov, 2023

Top 6 Programming Languages Used by Google

Top 6 Programming Languages Used by Google

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
Accenture creates a regulatory document authoring solution using AWS generative AI services

Accenture creates a regulatory document authoring solution using AWS generative AI services

February 6, 2024
Managing PDFs in Node.js with pdf-lib

Managing PDFs in Node.js with pdf-lib

November 16, 2023
23 Plagiarism Facts and Statistics to Analyze Latest Trends

23 Plagiarism Facts and Statistics to Analyze Latest Trends

June 4, 2024
Azul cloud service spots dead code in Java apps

Azul cloud service spots dead code in Java apps

October 7, 2023
The 15 Best Python Courses Online in 2024 [Free + Paid]

The 15 Best Python Courses Online in 2024 [Free + Paid]

April 13, 2024
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In