I want to put it in a <style> tag, but throughout the years I read time and again that it’s not possible to put @media screen and codes inside style tags (at least with the standard syntax).
Now in year 2022, is there any “good” way to do so? Thanks,
Do you have a sample piece of code to show what you’re trying to do that fails? I have to say I use media queries all the time with “screen” and they work fine. I use them in external style sheets, but to my knowledge they will work fine inside a section too.
Have you tried adding a media query inside your style tag to see if it works?
/* I always use @media only - also I have noticed 675px is a great overall mobile breakpoint.*/
@media only screen and (max-width:675px) {
.example {
display: block;
}
}
It’s ok I think people will get the gist of the conversation
Yes using media queries in style attributes will not work because that’s not what they were designed for and doesn’t really make any sense. I can’t really think of a ‘use-case’ for this anyway so perhaps if you explain what and why you think you need them then we may be able to offer an alternative answer.