# Media Queries aren't working in Codepen

**URL:** <https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136>\
**Category:** Curriculum Help\
**Tags:** css, html\
**Created:** [June 9, 2021, 8:23am UTC](https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136 "2021-06-09T08:23:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pola](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/pola/32/222084_2.png) [@Pola](https://forum.freecodecamp.org/u/Pola)\
**Post date:** [June 9, 2021, 8:23am UTC](https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136/1 "2021-06-09T08:23:03Z")

</div>

Hey,  
I am new to web development and I recently started to work on the Produkt Landing Page-Project. I was writing the code with Visual Studio Code and everything worked fine there, but the media queries don’t behave as they should after I uploaded the code to codepen.  
Can somebody point me out, where I made a mistake? 🙃

Here’s the link to my codepen  
[ProductLandingPage Codepen](https://codepen.io/BumBumBurka/pen/yLMEdGo)

```auto
@media (max-width: 420px) {
    header {
        font-size: 0.7em;
    }
}

@media (max-width: 600px) {
    .FlexInhalte {
     flex-direction: column;
    }
    
    h2 {
        text-align: center;
    }

    iframe {
        width: 280px;
        height: auto;
    }
}

@media (max-width: 860px) {
    header {
        flex-shrink: 7;
    }

    nav > ul {
        display:flex;
        flex-direction: column;
        justify-content: space-around;
        width: 35vw;
    }
}

```

---

<div class="post-metadata">

**Author:** ![Arskeliss](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/arskeliss/32/217601_2.png) [@Arskeliss](https://forum.freecodecamp.org/u/Arskeliss)\
**Post date:** [June 9, 2021, 10:33am UTC](https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136/2 "2021-06-09T10:33:38Z")

</div>

Hey,

Welcome,

The correct form of using `@media` query if the following:

```auto
@media only screen and (max-width: 460px){
    /*Here comes the actual code*/
}

```

At `.FlexInhalte` class maybe you want to specify the `display: flex;` property for the `flex-direction: column;` to work properly, because I didn’t see it specified anywhere else in your code.

Also, you could check out the [@media query types](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#media_types) for further reference.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![Annestezia](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/annestezia/32/74275_2.png) [@Annestezia](https://forum.freecodecamp.org/u/Annestezia)\
**Post date:** [June 9, 2021, 12:37pm UTC](https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136/3 "2021-06-09T12:37:08Z")

</div>

Hey,  
If you check browser inspector you’ll see that media queries are applied but some of them are overwritten by other css  
You can either increase [specificity of selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) in media-queries or move media-queries to the end of your css or after the rules for selectors you apply them to  
Hope this is understandable  
++theres a missing bracket the easiest way to find it is use codepen analyze tool

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [June 9, 2021, 2:43pm UTC](https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136/4 "2021-06-09T14:43:07Z")

</div>

`max-width` media queries should come after the rules they are meant to overwrite, not before.

```auto
body {
  background: red;
}

@media (max-width: 800px) {
  body {
    background: blue;
  }
}

```

---

<div class="post-metadata">

**Author:** ![Pola](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/pola/32/222084_2.png) [@Pola](https://forum.freecodecamp.org/u/Pola)\
**Post date:** [June 9, 2021, 2:57pm UTC](https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136/5 "2021-06-09T14:57:01Z")

</div>

That nailed it! Thank you so much for helping me out 👍 ❤

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [December 9, 2021, 2:57am UTC](https://forum.freecodecamp.org/t/media-queries-arent-working-in-codepen/464136/6 "2021-12-09T02:57:09Z")

</div>

Closed on December 9, 2021, 2:57am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
