CSS Tutorial
Colours, fonts and layout for your pages.
Getting started10 lessons
- 1CSS IntroductionStyling HTML with rules.
- 2CSS SyntaxSelectors, properties and values.
- 3Adding CSS to a PageInline, internal and external styles.
- 4CSS CommentsNotes that browsers ignore.
- 5How To Add CSSCSS can be inline with the style attribute, internal in a style element or external in a l.
- 6Rules, Selectors and DeclarationsA rule has a selector and a declaration block.
- 7Absolute and Relative Unitspx is fixed.
- 8Values: Keywords, Numbers and FunctionsValues can be keywords such as auto, numbers with units, colours, strings and functions su.
- 9Shorthand PropertiesShorthands set several properties at once: margin, padding, border, background, font and f.
- 10Why CSS Does Not ApplyCommon reasons: a typo in a property, a missing semicolon, a more specific rule winning, a.
Selectors17 lessons
- 11Basic SelectorsElement, class and id selectors.
- 12Universal and Grouping SelectorsMatching everything, or several things at once.
- 13CombinatorsSelecting by relationship.
- 14Pseudo-classesStyling states and positions.
- 15Pseudo-elementsStyling parts of an element.
- 16Attribute SelectorsSelecting by HTML attributes.
- 17Specificity and the CascadeWhich rule wins.
- 18InheritanceValues passed down to children.
- 19Class and ID SelectorsA class selector starts with a dot and can be reused.
- 20Element Selectors and Selector ListsAn element selector targets all tags of a type.
- 21Descendant and Child SelectorsA space selects any descendant.
- 22Sibling Selectors+ selects the element right after another.
- 23Attribute Selectors in DepthSelect by attribute presence, exact value or partial match: [href], [type="text"], [href^=.
- 24First, Last and nth ChildStructural pseudo classes pick elements by position: :first-child, :last-child, :nth-child.
- 25Form State Pseudo ClassesStyle form states with :focus, :checked, :disabled, :required, :valid and :invalid.
- 26::before and ::afterThese pseudo elements insert generated content before or after an element.
- 27::first-line, ::first-letter and ::selection::first-letter styles a drop cap, ::first-line the first line and ::selection the highligh.
Colours and backgrounds9 lessons
- 28ColoursNames, hex, rgb and hsl.
- 29BackgroundsBackground colour and shorthand.
- 30Background ImagesRepeat, position and size.
- 31GradientsLinear and radial colour blends.
- 32Colour FormatsCSS accepts names, hex such as #14b8a6, rgb(), rgba(), hsl() and modern formats.
- 33Opacity versus Transparent Coloursopacity makes the whole element and its children transparent.
- 34Background Position, Size and Repeatbackground-repeat tiles an image, background-position places it and background-size contro.
- 35Multiple BackgroundsStack several backgrounds separated by commas.
- 36Linear, Radial and Conic Gradientslinear-gradient blends along a line, radial-gradient from a centre and conic-gradient arou.
Box model15 lessons
- 37The Box ModelContent, padding, border and margin.
- 38BordersStyle, width and colour.
- 39Rounded CornersSoften edges with border-radius.
- 40MarginsSpace outside the border.
- 41PaddingSpace inside the border.
- 42Width and HeightSizing elements.
- 43Box SizingMake width include padding and border.
- 44OutlinesLines outside the border.
- 45Margin Collapse and Auto MarginsVertical margins of neighbouring blocks collapse into the larger one.
- 46Padding versus MarginPadding is space inside the border and shows the background.
- 47Border Styles and Individual SidesBorder styles include solid, dashed, dotted, double and groove.
- 48Rounded Corners in Depthborder-radius accepts one to four values and a slash for elliptical corners.
- 49Box Shadowbox-shadow takes x offset, y offset, blur, spread and colour.
- 50display, visibility and hiddendisplay: none removes an element from layout.
- 51min and max Width and Heightmax-width stops a box growing too wide while letting it shrink.
Text and fonts10 lessons
- 52FontsFamily, size, weight and style.
- 53Text StylingColour, alignment, decoration and case.
- 54Spacing and ShadowsLine height, letter spacing and text-shadow.
- 55CSS Unitspx, em, rem, %, vw and vh.
- 56Font Families and Web Fontsfont-family lists fonts in order with a generic fallback such as sans-serif.
- 57Font Weight, Style and Variantfont-weight accepts 100 to 900, normal and bold.
- 58Text Alignment and Decorationtext-align positions text.
- 59Line Height, Letter and Word Spacingline-height sets space between lines, letter-spacing between characters and word-spacing b.
- 60Text Overflow and Wrappingwhite-space: nowrap stops wrapping and text-overflow: ellipsis shows three dots when text .
- 61Text Shadow and Writing Modetext-shadow adds shadows to text with x, y, blur and colour.
Links, lists and tables7 lessons
- 62IconsEmoji and inline SVG.
- 63Styling LinksThe four link states.
- 64Styling ListsBullets, numbers and custom markers.
- 65Styling TablesBorders, spacing and stripes.
- 66Styling Links and ButtonsStyle link states in order: link, visited, hover, active (LoVe HAte).
- 67Custom List Markerslist-style-type, list-style-image and ::marker change bullets.
- 68Table Layout with CSStable-layout: fixed gives equal columns and faster rendering.
Layout11 lessons
- 69Display and VisibilityBlock, inline, inline-block and hiding.
- 70Position and z-indexStatic, relative, absolute, fixed, sticky.
- 71OverflowWhen content is bigger than its box.
- 72Float and ClearWrapping text around an element.
- 73Centering ThingsHorizontal and vertical centring.
- 74Block, Inline and Inline-blockBlock elements take the full width and start a new line.
- 75Static, Relative, Absolute and Fixedstatic is normal flow.
- 76z-index and Stackingz-index sets stack order for positioned elements.
- 77Overflow, Scroll and Resizeoverflow controls content that does not fit: visible, hidden, scroll and auto.
- 78Float and Clearfloat pushes an element left or right so text wraps around it.
- 79Centering Cheat SheetHorizontal: margin auto for blocks, text-align for text.
Flexbox8 lessons
- 80Flexbox BasicsOne dimensional layout made easy.
- 81Flex Container PropertiesDirection, wrap, alignment and gap.
- 82Flex Item Propertiesgrow, shrink, basis and order.
- 83Flex Direction and Wrapflex-direction chooses row or column.
- 84justify-content and align-itemsjustify-content places items along the main axis.
- 85flex-grow, flex-shrink and flex-basisflex-grow shares extra space, flex-shrink shrinks items when space is short and flex-basis.
- 86Order, Gap and align-selforder changes visual order, gap adds space between items and align-self overrides alignmen.
- 87Flexbox: Navbar and CardsA navbar is a flex row with space-between.
Grid8 lessons
- 88Grid BasicsTwo dimensional layout with rows and columns.
- 89Grid Areas and PlacementNamed areas and line numbers.
- 90Responsive Gridsauto-fit, minmax and auto-flow.
- 91Grid Template AreasName areas with grid-template-areas and place items with grid-area.
- 92Grid Tracks, fr and minmaxgrid-template-columns defines tracks.
- 93Grid Lines and SpanningItems can start and end on numbered lines with grid-column and grid-row, or span tracks wi.
- 94Grid Alignmentjustify-items and align-items align inside cells.
- 95Auto Placement and Dense Packinggrid-auto-flow chooses how items fill the grid.
Effects9 lessons
- 96Opacity and Box ShadowTransparency and depth.
- 97Hover and TransitionsSmall animations that make a page feel alive.
- 982D TransformsMove, rotate, scale and skew.
- 99AnimationsKeyframes that run on their own.
- 100Transitions in Depthtransition animates a property change.
- 1012D and 3D Transformstransform moves, rotates, scales and skews.
- 102Keyframe Animations@keyframes define steps.
- 103CSS Filtersfilter applies blur, brightness, contrast, grayscale, hue-rotate, invert, saturate and dro.
- 104Cursor, Pointer Events and User Selectcursor changes the pointer shape.
ComponentsPremium4 lessons
Responsive design8 lessons
- 109Responsive Design and Media QueriesMaking pages work on every screen.
- 110Responsive Images and object-fitImages that fit any box.
- 111Media QueriesMedia queries apply CSS by screen features: min-width, max-width, orientation, prefers-col.
- 112Mobile First StrategyWrite base styles for phones, then add min-width queries for larger screens.
- 113Viewport Units and Fluid Layoutvw and vh are percentages of the viewport.
- 114Responsive Navigation PatternA responsive nav stacks links on small screens and sits in a row from a breakpoint up.
- 115Responsive Backgrounds and ImagesUse max-width: 100%, object-fit and image-set() for flexible images.
- 116CSS and AccessibilityUse enough colour contrast, never remove focus outlines without replacing them, support zo.
AdvancedPremium6 lessons
Projects4 lessons
- 123Project: Responsive NavbarBuild a logo plus link list that stays in a row on desktop and stacks on small screens.
- 124Project: Card GridMake a responsive card grid with auto-fit and minmax.
- 125Project: Landing Page StylesStyle a landing page: hero with gradient, centred content, feature grid and a call to acti.
- 126Project: Dark and Light ThemeDefine colours as variables on :root, override them for a dark class or prefers-color-sche.
Advanced CSSPremium15 lessons
- 127Container QueriesContainer queries style a component based on the width of its container instead of the who.
- 128The :has() SelectorThe :has() pseudo class selects an element based on what it contains, so it works as a par.
- 129Selector Lists: :is(), :where() and :not()Use :is() to shorten repeated selectors and :not() to exclude things.
- 130Cascade Layers@layer groups rules into layers.
- 131Native CSS NestingModern CSS lets you nest rules inside each other without Sass.
- 132Subgridsubgrid lets a nested grid use the tracks of its parent grid, so items in different cards .
- 133Scroll Snapscroll-snap-type makes a scroll container settle on exact positions, like carousels.
- 134aspect-ratio and object-fitaspect-ratio keeps a box at a fixed shape such as 16 / 9.
- 135Logical PropertiesLogical properties use start and end instead of left and right, so layouts work in right t.
- 136clip-path and Masksclip-path cuts an element to a shape such as a polygon or circle.
- 137Filters and Blend Modesfilter applies effects such as blur, brightness and grayscale.
- 138Modern Colour Functionscolor-mix() blends two colours.
- 139@property: Typed Variables@property registers a custom property with a type, so the browser can animate it.
- 140Sticky Positioningposition: sticky keeps an element in normal flow until it reaches a scroll offset, then st.
- 141Columns and Gap UtilitiesCSS columns flows text into several columns.
CSS in practicePremium9 lessons
- 142Naming and Architecture: BEMBEM names classes by Block, Element and Modifier: .card, .card__title, .card--featured.
- 143Resets and Sensible DefaultsA small reset removes surprises: box-sizing border-box, margin removal on headings, respon.
- 144Fluid Typography and Spacingclamp(min, preferred, max) makes sizes grow smoothly with the viewport.
- 145Respecting Reduced MotionSome users get sick from animation.
- 146Rendering PerformanceSmooth pages avoid layout thrash and heavy effects.
- 147Debugging CSSUse the browser inspector to see applied rules, specificity, the box model and computed va.
- 148Project: Pricing CardsCombine grid, custom properties and hover states into a pricing section.
- 149Project: Hero SectionA hero uses grid or flex to centre content, a gradient background, readable contrast and a.
- 150CSS Review ChecklistBefore shipping check: no horizontal scroll on phones, focus styles visible, contrast pass.