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

    Design values, direction and motion · Lesson 13 of 17

    CSS custom properties and functions

    Shared values, fallbacks and calculated sizes.

    8 minutes1 games

    Custom property names start with -- and are read with var(). They follow the cascade and inherit by default, so a container can theme its descendants. A var fallback handles an unavailable or invalid custom property; it does not ensure any supplied value is valid for the final property.

    HTML
    <style>
      :root {--accent:teal;--space:12px;}
      .card {color:var(--accent, navy);padding:calc(var(--space) * 2);border:2px solid currentColor;}
      .warm {--accent:maroon;}
    </style>
    <div class="card">Default</div><section class="warm"><div class="card">Overridden</div></section>

    Define --accent

    Inherit or override

    Read with var()

    Important

    Use spaces around + and - in calc: calc(100% - 2rem).

    Interview question

    Are CSS variables equivalent to preprocessor variables?

    Exercise

    Define --accent as purple on .theme and use it for .label text.

    HTML
    <style></style><div class="theme"><p class="label">Theme</p></div>

    Learn more from

    • MDN: CSS referencedeveloper.mozilla.org
    • web.dev: custom-propertiesweb.dev

    Played 0 of 1 games

    Sign in to save your progress and earn XP.

    PreviousContainer-based responsivenessNextLogical properties for RTL and LTR
    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.