DEV Community

Cover image for New CSS media queries syntax šŸ’„

New CSS media queries syntax šŸ’„

Nikola PeriÅ”ić on June 18, 2024

Say goodbye to Min-Width & Max-WidthšŸ‘‹šŸ» The new CSS media query syntax changes how we define responsive breakpoints. It makes our c...
Collapse
 
kooiinc profile image
KooiInc

Thanks, good to know.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

I'm glad you like it. Make sure to follow me to keep up with more content like this šŸ˜€

Collapse
 
deejuh719 profile image
K Surratt

This makes it so much easier to remember than going "wait... does max mean up to or....?" Thank you!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah, absolutely. Thank you for your support!

Collapse
 
randy918 profile image
randy918

My brain doesn't think straight regarding min-width, etc. It always stops me to think it out. This new way is beautiful and instant to read.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Agree

Collapse
 
stkarlkode profile image
StKarl-kode

Interesting. Thanks mate

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
darshanagravat profile image
Darshan Agravat

šŸ„¹šŸ„¹šŸ„¹
I am so happy.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

dattebayo

Collapse
 
ademagic profile image
Miko

Hah, fantastic :) Strange to think it wasn't always written in this way!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Haha, exactly!

Collapse
 
tevin_enadeghe_906b3c9eb3 profile image
Tevin Enadeghe

This is really cool

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support :)

Collapse
 
sharada_marasinha_75ee54d profile image
Sharada Marasinha • Edited

Thank you bro..

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome! Thank you for your support :)

Collapse
 
uthmanhub profile image
Uthman Sarafadeen

Thanks so much, I was actually in search of a way of achieving exactly what the accent-color does after reading this post and luckily enough I found it here in a much easier way...

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thanks for support :)

Collapse
 
tbeaumont79 profile image
Thibault Beaumont

Thank for the share !

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome!

Collapse
 
syedmuhammadaliraza profile image
Syed Muhammad Ali Raza

nice

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you :)

Collapse
 
ermmes profile image
Emerson Campos

Interesting! Thanks for share!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :) Follow me to stay updated

Collapse
 
thiruxd profile image
ThiruXD ā™”ļøŽ

Nice!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you

Collapse
 
machineno15 profile image
Tanvir Shaikh

finally they are here.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah! :)

Collapse
 
aqilaziz profile image
Aqil Aziz

Amazing

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thanks

Collapse
 
arfinhasib profile image
ArfinHasib

Thanks. This looks promising. I'll definitely try it out.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
rabbiislamrony profile image
rabbi islam

thank you

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support!

Collapse
 
jacob_boluwatife_1bbf7d40 profile image
Jacob Boluwatife

This is nice and it will make written codes faster

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Agree. Thank you for your support

Collapse
 
jacob_boluwatife_1bbf7d40 profile image
Jacob Boluwatife

No prob šŸ™‚

Collapse
 
tranbaohuu profile image
Tran Bao Huu • Edited

Thanks for your information.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome

Collapse
 
adhishthanashok profile image
Adhishthan Ashok

Thanks! For the update.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :) Thank you for your support!

Collapse
 
dfr3sh1 profile image
DFr3sh

Thanks for this tip !

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome! Thank you for your support :)

Collapse
 
temaroon profile image
Aditya

This made it much clear for beginners.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah. It is much more clean now

Collapse
 
melchizedek404 profile image
Melchizedek Amos

Thank you for this

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support :)

Collapse
 
mdrejon profile image
Sydur Rahman

Wow That's awesome .

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah! Thank you for your support :)

Collapse
 
duck18 profile image
duck

this syntax is more readable and intuitive

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Agree with you :) Follow me to stay updated

Collapse
 
wilmela profile image
Wilmela

Good info

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Glad you like it :)

Collapse
 
fmagrosoto profile image
Fernando Magrosoto

Thank you for your input

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support

Collapse
 
divyesh_kakrecha_221ac450 profile image
Divyesh Kakrecha

Thanks for this update.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

No problem amigo! Follow me to stay updated :)

Collapse
 
damienschneider profile image
Damien Schneider

So much clearer, no one can be against this change. Love this.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Totaly agree :)

Collapse
 
rujorgensen profile image
rujorgensen

Love it, I never understood the old syntax

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Same

Collapse
 
abdul_moeed_ec5854013f356 profile image
Abdul Moeed

Good

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support

Collapse
 
safwatman profile image
Safwat Ahmed

Amazing!! I tried it immediately and it is super easy to understand!! I'm very happy now because I'm always get confused in this media queries šŸ˜‚šŸ˜‚šŸ˜‚
Thanks! I really appreciate it ā¤ā¤ā¤

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support :)

Collapse
 
kaitabassum profile image
Kainat

Thanks for the update

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
mohamed_aldabaan_261fbd47 profile image
Mohamed AlDabaan

cool

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Glad you like it :) Follow me to stay updated

Collapse
 
kevinbism profile image
Kevin Ramirez

Finally a simple syntax. Thanks!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
fadekocodeit profile image
Future_Developer

Thanks for sharing šŸ‘

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
kamlesh_suthar_53 profile image
Kamlesh Suthar

This syntax is look like a simple to implement by replaces of Max and min width.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah, agree

Collapse
 
sorena_salehi profile image
Sorena salehi

I'm feel free now šŸ˜‚šŸ˜‚ā¤ļø

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

hahah, same!

Collapse
 
kevinkev profile image
Kevin kev

Wow amazing

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support :)

Collapse
 
avelowski profile image
Avel

Sigma

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

giga chad

Collapse
 
johnravee profile image
John Rave Mimay

Thank you for the info.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome! Follow me to stay updated :)

Collapse
 
aqib_shoaib_460d14658d79a profile image
Aqib Shoaib

will try for sure....

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thanks for reading my blog post :)

Collapse
 
vitalves profile image
vitalves

Very nice!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for reading my blog post!

Collapse
 
syedmaazsaeed profile image
Syed Maaz Saeed

Great .

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thanks :)

Collapse
 
nyein_swe_ced0776ab0990d8 profile image
Nyein Swe

Thanks , like it šŸŽØ

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome! Thank you for your support :)

Collapse
 
zubayer_aurnab_f0f3fdfe25 profile image
Zubayer Aurnab

thats great !

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah :) Thank you for your support!

Collapse
 
sattar007 profile image
Mohamed Abdel Sattar

Thanks for the update. it's fascinating.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
abdessalam_barka profile image
Abdessalam Barka

Thank you for the update

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
korie_chisom_432709203df4 profile image
Korie Chisom

Very wonderful and less time consuming, thanks šŸ˜ŠšŸ’•

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :) Thank you for your support!

Collapse
 
dev_unbelievable profile image
Dev unbelievable

thanks

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
anujsamdariya07 profile image
Anuj Samdariya

Thanks for sharing !

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :) Follow me to stay updated

Collapse
 
tablepad profile image
Tablepad

Cool, thanks!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome!

Collapse
 
vandinelsonrocha profile image
Vandinelson Rocha

Eu sempre pensei porque nĆ£o se usava a sintaxe assim, feliz por saber que agora jĆ” Ć© possĆ­vel usar...šŸ˜Š

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Obrigado pelo seu apoio!

Collapse
 
adrian_gharineh profile image
Adrian Gharineh

I'm just starting out in my development journey but this seems much more intuitive to me than max-width and min-width. Thank you for sharing!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome! Thank you for your support :)

Collapse
 
adamj_web_dev profile image
Adam Johnson

Oh yes I love this.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Me too :) Follow me to stay updated

Collapse
 
alpha_alpha_c1aaed1d10758 profile image
Alpha Alpha

Good !!!!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support

Collapse
 
qeshela profile image
Nikoloz Keshelashvili

is it supported in all browsers?

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

you can check it here: caniuse.com/?search=media%20queries

Collapse
 
emmy3131 profile image
Emmy3131

Wow I love this very unique

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support :)

Collapse
 
gitmbints profile image
Mbints

When I saw the simpler syntax '>=' , I initially thought I preferred the old syntax, but it seems like this one is easier to read.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yep agree

Collapse
 
mohamed_messaoudene profile image
MOHAMED MESSAOUDENE

Thanks šŸ‘ but I think it is much easier with tailwind css

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome!

Collapse
 
jarzdev profile image
Javier

also you can use minmax to vary with @media, thank you for this !

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
grigoriy_ko_966f81216f54c profile image
Grigoriy Ko

Good news, thanks!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
shajim profile image
SHAJIM

It's look like same . I think that's way not too much useful.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Well, 2k people don't agree with you

Collapse
 
prathamesh_sawant_f5751ab profile image
Prathamesh Sawant

More readability less code, finally a better abstraction

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah, finally!

Collapse
 
ozoani_valentine_fc8a75c6 profile image
Ozoani Valentine

Thanks for the help, I really enjoyed it

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Glad you liked it :)

Collapse
 
joshuajohn11 profile image
Joshua 11

I love it, and it's beginner friendly

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Glad you liked it :)

Collapse
 
awaismadni97 profile image
Awais Naveed

Thanks for this valuable tip :)

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Glad you liked it :)

Collapse
 
lexyvng profile image
Alexia

Very useful. Thank you!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Follow me to stay updated :)

Collapse
 
teewheelz profile image
Teewheelz

Thats soo helpful

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

No problem :) Follow me to stay updated :)

Collapse
 
mayor profile image
Mayowa

This is so much easier to understand!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Agree! Thank you for your support :) Follow me for more :)

Collapse
 
e-tech profile image
Onyedikachi Emmanuel Nnadi

nice

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support :)

Collapse
 
webdevop-mudasir profile image
Mudasir Abbas Phulpoto

Well bro, to share latest syntax of css

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thank you for your support. Follow me to stay updated :)

Collapse
 
anas_alhomsi_bf7397a007e6 profile image
Anas ALhomsi

It is so good and beautiful

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Thanks for supporting :) Follow me for more :)

Collapse
 
sagarj521 profile image
Sagar jadhav

Good one

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Absolutely!

Collapse
 
hien_posley_0e4f0e2bd5af9 profile image
Hien Posley

It's amazing

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yeah!

Collapse
 
dnaite profile image
Setiya Budi

I love this one, definitely simpler instead of thinking about min and max. Thank's for the update!

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

You're welcome :)

Collapse
 
sandip2196 profile image
Sandip Bhambre (Sandy)

What about compatibility with Browsers? šŸ¤”

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić
Collapse
 
talison-cardoso profile image
TƔlison Cardoso

JĆ” usei dessa forma em uma aplicaĆ§Ć£o que fiz no final do ano passado, mas nĆ£o teve (pelo menos na Ć©poca) uma boa compatibilidade com o Safari no mobile.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Image description

Collapse
 
kartofelek007 profile image
kartofelek007

I don't know how it is with these safari updates, but after applying the new @media I immediately got a return from a customer with a new iphone that in his case does not work. After changing to the old one everything was laughing.

Thread Thread
 
talison-cardoso profile image
TƔlison Cardoso

exactly, even though caniuse.com shows that as of safari 16.4 it already works, the failure still happens.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić
Collapse
 
lazylad profile image
Tathagat

Does SCSS supports this yet?

Collapse
 
god7139 profile image
God7139

Inequality concept of mathematics_! Liked it & Good to know.

Collapse
 
usmanlubis profile image
Usman Lubis

how about the browser support?

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić • Edited

I talked about that in the article and provided link..
caniuse.com/?search=media%20queries

Collapse
 
its_kundan profile image
Kundan Kumar

Is this valid in tailwind CSS?

Collapse
 
taffy_ruzz profile image
Tafadzwa Ruzvidzo

Do this work on media queries only or on any CSS that need min-width and max-width.

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić

Yes

Collapse
 
marton_gombos_67d94a238db profile image
Marton Gombos

Thatā€™s nothing revolutionary ā€“ to be honest it might be more readable, but not by much

Collapse
 
perisicnikola37 profile image
Nikola PeriÅ”ić • Edited

Thank you for your comment :)

While the new CSS media query syntax may not appear revolutionary at first glance, it actually brings several key advantages that can significantly enhance how we develop responsive web pages.

  1. Code clarity(as you said): The new syntax is simple and intuitive
  2. Easier syntax for beginners: The simplified syntax reduces confusion, making it easier for newcomers to grasp how media queries work. Instead of juggling min-width and max-width, they can now use straightforward conditions that directly apply to elements
  3. Development efficiency: Reduced complexity leads to faster CSS writing

The real revolution lies in simplifying the process of defining breakpoints and conditions for responsive design.

I appreciate your thoughts and encourage further exploration of how these changes impact our workflows positively.