Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    { }CSS

    Styling foundations

    • What is CSS?
    • Cascade and specificity
    • Selectors and element states
    • Colours and text

    Boxes and sizing

    • Padding, border and margin
    • Units and flexible sizing
    • Overflow and image fitting

    Layout and responsiveness

    • Flexbox
    • CSS Grid
    • Positioning and stacking
    • Responsive design
    • Container-based responsiveness

    Design values, direction and motion

    • CSS custom properties and functions
    • Logical properties for RTL and LTR
    • CSS transitions and transforms
    • Keyframes and bounded animation
    • Project: a product card
    CSS

    Layout and responsiveness · Lesson 11 of 17

    Responsive design

    One page that looks right on phones and computers.

    8 minutes2 games

    A media query applies CSS only above or below a screen size. The common approach is “mobile first”: style for phones first, then add rules for bigger screens with @media (min-width: 700px) { ... }.

    HTML
    <style>
      .cards { display: grid; gap: 10px; grid-template-columns: 1fr; }
      .cards div { background: #fef3c7; padding: 16px; border-radius: 8px; }
    
      @media (min-width: 500px) {
        .cards { grid-template-columns: repeat(3, 1fr); }
      }
    </style>
    
    <div class="cards">
      <div>One</div><div>Two</div><div>Three</div>
    </div>

    The preview is wide, so you'll see 3 across. On a phone they stack.

    Important

    Choose breakpoints based on content needs, not device models. Test intermediate widths too.

    Interview question

    Does a media query measure a card’s width?

    Never forget this line in every page's <head>: <meta name="viewport" content="width=device-width, initial-scale=1">. Without it phones show the page tiny.

    Quick question

    When does @media (min-width: 900px) apply?

    Order the lines

    Put the media query in order.

    1. Click the lines in the right order

    Learn more from

    • MDN: CSS referencedeveloper.mozilla.org
    • web.dev: media-queriesweb.dev

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousPositioning and stackingNextContainer-based responsiveness
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.