G.O.C
· CSS Course: From Beginner to Responsive Layouts
Teacher mode
◐ Theme
Present
◀ Prev
Next ▶
+
−
Fit
Expand all
Collapse
# CSS Course: From Beginner to Responsive Layouts ## Course Overview ### About this course 28 Oct 2026 · @G.O.C. This course takes a complete beginner to building responsive, modern web pages with CSS. The lesson order follows the chapter flow of the W3Schools CSS Tutorial (core tutorial, advanced, Flexbox, Grid, responsive design, Sass). All explanations and code examples are written for teaching, so use W3Schools alongside as a reference and for its Try it Yourself editor (w3schools.com/css/default.asp). Who it is for: beginners who know basic HTML (headings, paragraphs, links, lists, images, forms). !Each module ends with a mini project that builds toward the final capstone. ### What students can do by the end Style any HTML page with colors, fonts, spacing, borders and backgrounds. Control layout with the box model, positioning, Flexbox and Grid. Build navigation bars, dropdowns, forms, buttons and cards. Make pages that adapt to phones, tablets and desktops. Add transitions and animations, and organize CSS with variables. ### Tools needed A code editor (VS Code recommended), Chrome or Edge with DevTools (press F12), and a folder with index.html and style.css. ### How each module works Learning goals, short lessons with code, a hands-on practice task, and a checkpoint. Each module ends with a mini project that builds toward the final capstone. ### Schedule (10 weeks) Week 1, Module 1, CSS foundations: Intro, Syntax, Selectors, How To, Comments, Errors. Week 2, Module 2, Colors, backgrounds and the box model: Colors, Backgrounds, Borders, Margins, Padding, Height/Width, Box Model, Outline. Week 3, Module 3, Text, fonts, links, lists and tables: Text, Fonts, Icons, Links, Lists, Tables. Week 4, Module 4, Display and positioning: Display, Max-width, Position, Z-index, Overflow, Float, Inline-block, Align. Week 5, Module 5, Smarter selectors: Combinators, Pseudo-classes, Pseudo-elements, Opacity, Attribute Selectors. Week 6, Module 6, Components and how CSS decides: Navbars, Dropdowns, Gallery, Sprites, Forms, Counters, Units, Inheritance, Specificity, !important, Website Layout. Week 7, Module 7, Advanced effects: Rounded corners, Gradients, Shadows, Transforms, Transitions, Animations, Tooltips, Images, Buttons, Pagination, Columns. Week 8, Module 8, Flexbox and Grid: Flexbox Intro/Container/Items/Responsive, Grid Intro/Container/Items/12-column. Week 9, Module 9, Responsive web design: RWD Intro, Viewport, Grid View, Media Queries, Images, Videos. Week 10, Modules 10 and 11, Modern CSS and Capstone: Variables, @property, Math Functions, Box Sizing, @supports, Optimization, Accessibility, Sass. !Teaching tip: run each session as 30% explanation, 70% practice. Students learn CSS by changing a value and watching the page react. ## Module 1: CSS foundations (Week 1) ### Learning goals Explain what CSS does, write a rule, target elements with basic selectors, and add CSS to a page in three ways. ### 1.1 What CSS is HTML describes what content is (a heading, a paragraph). CSS describes how it looks (color, size, spacing, position). Keeping them separate means one stylesheet can restyle an entire website. ### 1.2 Syntax: selector, property, value A CSS rule has a selector (what to style) and a declaration block (how to style it). Each declaration is a property: value; pair. Here h1 is the selector, color and text-align are properties, and darkblue and center are values. Every declaration ends with a semicolon. > h1 {\n color: darkblue;\n text-align: center;\n} ### 1.3 Selectors Element: p { } targets every p. Class: .card { } targets any element with class="card". ID: #header { } targets the one element with id="header". Universal: * { } targets every element. Grouping: h1, h2, h3 { } targets all three at once. > /* Group selectors to avoid repeating yourself */\nh1, h2, h3 {\n font-family: Arial, sans-serif;\n color: #333;\n}\n\n.highlight {\n background-color: yellow;\n} !Rule of thumb: use classes for styling, IDs sparingly, and element selectors for site-wide defaults. ### 1.4 Three ways to add CSS 1. External stylesheet (best practice): a separate .css file linked in the head. 2. Internal: a style block inside the HTML page. 3. Inline: a style attribute on one element. Avoid it except for quick tests. > \n
\n If several stylesheets or rules conflict, the cascade decides: later rules win over earlier ones when they are equally specific, and inline styles beat stylesheet rules. ### 1.5 Comments and errors Comments are for humans and are ignored by the browser. > /* This is a comment */ CSS fails quietly. A missing semicolon, a misspelled property or a missing brace makes the browser skip that declaration or even the next rule. When something does not work, open DevTools, inspect the element, and look for struck-through or warning-marked declarations. ### Practice and checkpoint Practice: create index.html with a heading, three paragraphs and a list. In style.css change the page background, center the heading, give paragraphs a font size, and make one paragraph stand out using a class. Checkpoint: 1. What are the two parts of a CSS rule? 2. When would you use a class instead of an ID? 3. Why is an external stylesheet usually the best choice? 4. What happens if you forget a semicolon between two declarations? Mini project: a one-page About me profile styled with an external stylesheet. ## Module 2: Colors, backgrounds and the box model (Week 2) ### Learning goals Use every color format, style backgrounds and borders, and explain the box model well enough to predict an element's size. ### 2.1 Colors Colors can be written as names, RGB, HEX or HSL, with optional transparency. > .a { color: tomato; } /* name */\n.b { color: rgb(30, 144, 255); } /* red, green, blue 0-255 */\n.c { color: #1e90ff; } /* HEX */\n.d { color: hsl(210, 100%, 56%); } /* hue, saturation, lightness */\n.e { background-color: rgba(0, 0, 0, 0.5); } /* 50% transparent black */ HSL is the friendliest for beginners: change the lightness to make shades of the same color. ### 2.2 Backgrounds > body {\n background-color: #f4f4f4;\n background-image: url("pattern.png");\n background-repeat: no-repeat;\n background-position: center;\n background-size: cover;\n background-attachment: fixed;\n}\n\n/* Shorthand */\nheader {\n background: #222 url("hero.jpg") no-repeat center / cover;\n} ### 2.3 Borders > .box {\n border: 2px solid #333; /* width style color */\n border-bottom: 4px dashed red; /* one side only */\n border-radius: 8px; /* rounded corners */\n} Common styles: solid, dashed, dotted, double, none. Setting border-radius: 50% on a square makes a circle. ### 2.4 The box model Every element is a rectangle made of four layers, from inside to outside: 1. Content: the text or image. 2. Padding: space between content and border (inside the box). 3. Border: the line around the padding. 4. Margin: space outside the border, pushing other elements away. > .card {\n width: 300px;\n padding: 20px;\n border: 2px solid #ccc;\n margin: 30px auto;\n} By default, width sets only the content width, so this card is actually 300 + 40 + 4 = 344px wide. Fix this with box-sizing: border-box, which makes the width include padding and border. > *, *::before, *::after {\n box-sizing: border-box;\n} ### 2.5 Margin and padding shorthand margin: 10px; sets all four sides. margin: 10px 20px; is top and bottom 10px, left and right 20px. margin: 10px 20px 30px; is top 10, left and right 20, bottom 30. margin: 10px 20px 30px 40px; is top, right, bottom, left (clockwise). margin: 0 auto; centers a block with a set width. !Margin collapse: when the vertical margins of two block elements touch, they merge into the larger one instead of adding up. Padding never collapses. ### 2.6 Height, width and limits > .container {\n width: 90%;\n max-width: 1000px; /* never wider than 1000px */\n min-height: 200px; /* never shorter than 200px */\n} max-width is the key to flexible layouts: the box shrinks on small screens but stops growing on large ones. ### 2.7 Outline An outline is drawn outside the border and does not take up space. It is mostly used for focus styles. > button:focus {\n outline: 3px solid orange;\n outline-offset: 4px;\n} ### Practice and checkpoint Practice: build a profile card: 300px wide, centered, light background, rounded border, padding inside, and a circular image. Open DevTools and hover over the card to see the colored margin, border and padding layers. Checkpoint: 1. What is the difference between margin and padding? 2. A box has width: 200px; padding: 10px; border: 5px solid. How wide is it with and without border-box? 3. Write margin shorthand for 5px top, 10px right, 15px bottom, 20px left. 4. Why use max-width instead of width on a container? Mini project: a business card and a three-card row with consistent spacing. ## Module 3: Text, fonts, links, lists and tables (Week 3) ### Learning goals Make text readable and attractive, load web fonts, style links as buttons, and format lists and data tables. ### 3.1 Text properties > p {\n color: #333;\n text-align: justify; /* left, right, center, justify */\n text-decoration: underline; /* none, underline, line-through */\n text-transform: capitalize; /* uppercase, lowercase, capitalize */\n letter-spacing: 1px;\n word-spacing: 4px;\n line-height: 1.6; /* unitless = multiple of font size */\n text-indent: 2em;\n text-shadow: 1px 1px 3px rgba(0,0,0,0.3);\n} A line-height of 1.5 to 1.7 is comfortable for body text. ### 3.2 Fonts > body {\n font-family: "Segoe UI", Tahoma, Arial, sans-serif;\n font-size: 16px;\n font-weight: 400; /* 400 normal, 700 bold */\n font-style: italic;\n} Font family is a list: the browser uses the first font it has, then falls back. Always end with a generic family (serif, sans-serif, monospace). Web-safe fonts (Arial, Verdana, Times New Roman, Courier New) exist on almost every device. Google Fonts adds more choices. Add the link in your HTML head, then use the name in CSS: >
> body { font-family: "Roboto", sans-serif; } Font pairing: pair a distinctive heading font with a plain, highly readable body font. Limit yourself to two families. Shorthand (style, weight, size/line-height, family): > font: italic 700 18px/1.5 Arial, sans-serif; ### 3.3 Icons Icon libraries such as Font Awesome, Bootstrap Icons and Google Material Icons are loaded through a stylesheet link and used with a class on an i or span tag. Because icons behave like text, you size and color them with font-size and color. ### 3.4 Links Links have four states. Write them in this order (remember LoVe HAte: link, visited, hover, active). > a:link { color: #0066cc; text-decoration: none; }\na:visited { color: #6a3d9a; }\na:hover { text-decoration: underline; }\na:active { color: red; } Turn a link into a button: > .btn {\n display: inline-block;\n padding: 10px 20px;\n background: #0066cc;\n color: white;\n border-radius: 6px;\n text-decoration: none;\n}\n.btn:hover { background: #004c99; } ### 3.5 Lists > ul {\n list-style-type: square; /* disc, circle, square, none */\n list-style-position: inside;\n}\n\n/* Remove bullets and default spacing, e.g. for menus */\nnav ul {\n list-style: none;\n margin: 0;\n padding: 0;\n} ### 3.6 Tables > table {\n border-collapse: collapse; /* merges double borders */\n width: 100%;\n}\nth, td {\n border: 1px solid #ddd;\n padding: 10px;\n text-align: left;\n}\nth { background: #222; color: white; }\ntr:nth-child(even) { background: #f6f6f6; } /* zebra stripes */\ntr:hover { background: #e9f2ff; } For wide tables on phones, wrap the table in a container with overflow-x: auto so it scrolls sideways instead of breaking the page. ### Practice and checkpoint Practice: style a course timetable: zebra-striped table with a dark header, a hover highlight, Google Font headings, and a Register link that looks like a button. Checkpoint: 1. Why must a:hover come after a:link and a:visited? 2. What does a generic font family do in a font stack? 3. Which property merges adjacent table borders? 4. How do you remove bullets from a list? Mini project: a restaurant menu page with styled headings, a price table, and a call-to-action button. ## Module 4: Display and positioning (Week 4) ### Learning goals Control how elements flow on the page, position them precisely, stack them, handle overflow, and center things in every direction. ### 4.1 The display property block: starts on a new line, fills the width (div, p, h1). inline: flows within text, width and height are ignored (span, a). inline-block: flows inline but accepts width, height, margin and padding. none: removed from the page completely. flex and grid: modern layout containers (Module 8). !display: none removes the element and its space. visibility: hidden hides it but keeps the empty space. ### 4.2 Position > .static { position: static; } /* default, normal flow */\n.relative { position: relative; top: 10px; left: 20px; } /* shifted from its own spot */\n.absolute { position: absolute; top: 0; right: 0; } /* placed relative to nearest positioned ancestor */\n.fixed { position: fixed; bottom: 20px; right: 20px; } /* stays on screen while scrolling */\n.sticky { position: sticky; top: 0; } /* normal, then sticks at the offset */ The classic pattern: make the parent position: relative and the child position: absolute so the child is placed inside the parent, for example a badge in the corner of a card. > .card { position: relative; }\n.card .badge {\n position: absolute;\n top: 10px;\n right: 10px;\n} ### 4.3 Z-index When positioned elements overlap, z-index decides which sits on top. Higher numbers win. It only works on positioned elements (anything except static) and on flex or grid items. > .modal { position: fixed; z-index: 1000; }\n.overlay { position: fixed; z-index: 999; } ### 4.4 Overflow What happens when content is bigger than its box? overflow: visible (default) spills out. hidden clips it. scroll always shows scrollbars. auto shows scrollbars only when needed. > .chat-box {\n height: 200px;\n overflow-y: auto;\n} ### 4.5 Float and clear float pushes an element left or right so text wraps around it. It was once used for whole page layouts, but today it is mainly for wrapping text around images. > img.portrait { float: left; margin: 0 15px 10px 0; }\n.clearfix::after { content: ""; display: table; clear: both; } Use the clearfix when a parent collapses because all its children are floated. ### 4.6 Inline-block Useful for navigation links or buttons that sit on one line but need padding and fixed sizes. Note that whitespace between inline-block elements in your HTML creates small gaps. ### 4.7 Centering Center text: text-align: center. Center a block horizontally: width: 600px; margin: 0 auto. Center anything both ways (modern): display: flex; justify-content: center; align-items: center. Absolutely positioned centering: > position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); ### Practice and checkpoint Practice: build a page with a sticky top bar, a card with a badge in its corner, an image with text wrapping around it, and a scrollable box with a fixed height. Then use DevTools to toggle position values and watch what changes. Checkpoint: 1. What is the difference between display: none and visibility: hidden? 2. Which ancestor does an absolutely positioned element use as its reference? 3. Why does z-index sometimes appear to do nothing? 4. How do you center a fixed-width block horizontally? Mini project: a landing page hero section with a centered headline, a fixed Back to top button, and an overlay banner. ## Module 5: Smarter selectors (Week 5) ### Learning goals Target elements by their relationship, state, position and attributes, and add decorative content without extra HTML. ### 5.1 Combinators Combinators select elements based on how they relate in the HTML tree. Descendant (space): article p selects every p anywhere inside article. Child (>): ul > li selects li that are direct children of ul. Adjacent sibling (+): h2 + p selects the first p right after an h2. General sibling (~): h2 ~ p selects all p that follow an h2 at the same level. > nav > ul > li { display: inline-block; }\nh2 + p { font-size: 1.2em; font-weight: bold; } /* lead paragraph */ ### 5.2 Pseudo-classes A pseudo-class styles an element in a particular state or position. Interactive states: > button:hover { background: #0055aa; }\ninput:focus { border-color: dodgerblue; }\ninput:disabled { opacity: 0.5; }\ninput:checked + label { font-weight: bold; } Structural pseudo-classes: > li:first-child { font-weight: bold; }\nli:last-child { border-bottom: none; }\ntr:nth-child(odd) { background: #f2f2f2; }\nli:nth-child(3n) { color: red; } /* every third item */\np:not(.note) { color: #333; } ### 5.3 Pseudo-elements A pseudo-element styles a part of an element or inserts generated content. It uses a double colon. > p::first-letter { font-size: 2.5em; float: left; } /* drop cap */\np::first-line { font-weight: bold; }\n::selection { background: gold; }\n\n/* Generated content: always set 'content' */\na[href^="http"]::after { content: " \2197"; }\n.required::before { content: "* "; color: red; } ::before and ::after are the most powerful: they let you add icons, decorations and clearfix hacks without touching the HTML. ### 5.4 Opacity > img { opacity: 0.6; }\nimg:hover { opacity: 1; } opacity fades the whole element including its text and children. To make only the background transparent, use rgba() or hsla() for the background color instead. ### 5.5 Attribute selectors > input[type="text"] { border: 1px solid #999; }\na[target] { color: green; }\na[href^="https"] { } /* begins with */\na[href$=".pdf"] { } /* ends with */\na[href*="example"] { } /* contains */\n[class~="card"] { } /* class list contains the word */ Attribute selectors let you style form inputs by type without adding classes. ### Practice and checkpoint Practice: build an FAQ list where odd rows have a light background, the first question is bold, external links show an arrow icon after them, and required form labels get a red asterisk using ::before. Checkpoint: 1. What is the difference between div p and div > p? 2. Write a selector for every third list item. 3. Why do ::before and ::after need the content property? 4. How do you select only links that end in .pdf? Mini project: a styled article page with a drop cap, striped table, external link icons, and hover effects on images. ## Module 6: Components and how CSS decides (Week 6) ### Learning goals Build real interface pieces (navbars, dropdowns, galleries, forms), use the right units, and predict which rule wins when styles conflict. ### Part A, 6.1 Navigation bars A navbar is just a list of links with the bullets removed. >
\n
\n
Home
\n
Courses
\n
Contact
\n
\n
> .navbar { list-style: none; margin: 0; padding: 0; background: #222; overflow: hidden; }\n.navbar li { float: left; } /* horizontal bar */\n.navbar a {\n display: block;\n padding: 14px 20px;\n color: white;\n text-decoration: none;\n}\n.navbar a:hover { background: #0066cc; } For a vertical menu, remove the float and give the list a fixed width. A flex version (display: flex; on the ul) is shorter and is what you will use in Module 8. ### 6.2 Dropdown menus Hide the menu, then reveal it when the parent is hovered. > .dropdown { position: relative; display: inline-block; }\n.dropdown-content {\n display: none;\n position: absolute;\n background: white;\n min-width: 160px;\n box-shadow: 0 8px 16px rgba(0,0,0,0.2);\n z-index: 1;\n}\n.dropdown:hover .dropdown-content { display: block; } ### 6.3 Image gallery and sprites A gallery is a row of bordered, hover-enabled images inside divs with captions. Image sprites combine many small icons into one image file and use background-position to show one icon at a time, which reduces the number of requests the browser makes. ### 6.4 Forms > input[type="text"], input[type="email"], select, textarea {\n width: 100%;\n padding: 12px;\n margin: 6px 0 16px;\n border: 1px solid #ccc;\n border-radius: 4px;\n box-sizing: border-box;\n}\ninput:focus, textarea:focus {\n border-color: #0066cc;\n outline: none;\n box-shadow: 0 0 0 3px rgba(0,102,204,0.2);\n}\ninput[type="submit"] {\n background: #0066cc;\n color: white;\n border: none;\n padding: 12px 24px;\n cursor: pointer;\n} !If you remove the default outline, always replace it with a visible focus style so keyboard users can see where they are. ### 6.5 Counters CSS can number headings automatically: > body { counter-reset: section; }\nh2::before {\n counter-increment: section;\n content: "Section " counter(section) ": ";\n} ### Part B, 6.6 Units px: absolute, one screen pixel. em: multiple of the parent's font size. rem: multiple of the root (html) font size. %: percentage of the parent. vw and vh: 1% of the viewport width and height. Good habit: use rem for font sizes and spacing, % or vw for widths, and px for borders and fine details. ### 6.7 Inheritance Some properties (like color, font-family, line-height) pass down from parent to child automatically. Others (like margin, border, padding) do not. You can force it with inherit, reset with initial, or use unset. ### 6.8 Specificity When two rules target the same element, the more specific selector wins. Score from highest to lowest: inline style, ID (#nav), class and attribute and pseudo-class (.card, [type], :hover), element and pseudo-element (p, ::before). If specificity is equal, the rule that appears later wins. Example: #nav a beats .menu a, which beats a. ### 6.9 !important !important overrides specificity, but it makes CSS hard to maintain. Treat it as a last resort, for example to override third-party styles you cannot edit. If you need it often, restructure your selectors instead. ### 6.10 Website layout A typical page is a header, a navigation bar, a main content area with optional sidebar, and a footer. Start with a single-column mobile layout, then add columns for larger screens (you will do this properly with Flexbox and Grid in Module 8). ### Practice and checkpoint Practice: build a header with a navbar and a dropdown, a contact form with focus styles, and a footer. Open DevTools and find a rule that is being overridden, then explain why using specificity. Checkpoint: 1. Why does the dropdown content need position: absolute? 2. What is the difference between em and rem? 3. Which wins: .card p or #main p? Why? 4. Why is !important discouraged? Mini project: a complete multi-section website shell (header, nav with dropdown, content, contact form, footer). ## Module 7: Advanced effects (Week 7) ### Learning goals Add depth and motion with gradients, shadows, transforms, transitions and animations, and polish images, buttons and other UI pieces. ### 7.1 Rounded corners, border images and backgrounds > .pill { border-radius: 999px; }\n.leaf { border-radius: 30px 0 30px 0; }\n.hero {\n background: url("stars.png") top left no-repeat, url("sky.jpg") center / cover; /* multiple backgrounds */\n background-clip: padding-box;\n} Earlier layers in a multiple-background list sit on top. background-size accepts cover (fill, may crop) and contain (fit, may leave gaps). ### 7.2 Gradients > .linear { background: linear-gradient(to right, #ff7e5f, #feb47b); }\n.angled { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }\n.radial { background: radial-gradient(circle, white, steelblue); }\n.conic { background: conic-gradient(red, yellow, green, blue, red); } ### 7.3 Shadows > .card {\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* x, y, blur, color */\n}\n.card:hover {\n box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);\n}\nh1 { text-shadow: 2px 2px 4px rgba(0,0,0,0.4); } Subtle shadows with low opacity look professional. Heavy black shadows look dated. ### 7.4 Text effects and custom fonts > .clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n.wrap { word-wrap: break-word; }\n\n@font-face {\n font-family: "BrandFont";\n src: url("brandfont.woff2") format("woff2");\n font-display: swap;\n}\nh1 { font-family: "BrandFont", sans-serif; } ### 7.5 2D and 3D transforms > .move { transform: translate(20px, 10px); }\n.turn { transform: rotate(15deg); }\n.grow { transform: scale(1.2); }\n.lean { transform: skew(10deg, 0); }\n.combo { transform: translateY(-4px) scale(1.05); }\n\n/* 3D */\n.scene { perspective: 800px; }\n.flip { transform: rotateY(180deg); transform-style: preserve-3d; } Transforms do not affect the layout of surrounding elements and are smooth to animate, so they are the best choice for hover and motion effects. 3D card flips use perspective, transform-style: preserve-3d and backface-visibility: hidden. ### 7.6 Transitions A transition animates the change between two states, usually on hover. > .btn {\n background: #0066cc;\n transition: background 0.3s ease, transform 0.2s ease;\n}\n.btn:hover {\n background: #004c99;\n transform: translateY(-2px);\n} Timing functions: ease, linear, ease-in, ease-out, ease-in-out, plus custom cubic-bezier() and steps(). ### 7.7 Animations Animations use @keyframes to define stages and the animation property to play them. > @keyframes fadeUp {\n from { opacity: 0; transform: translateY(20px); }\n to { opacity: 1; transform: translateY(0); }\n}\n.hero h1 {\n animation: fadeUp 0.8s ease-out both;\n}\n\n@keyframes pulse {\n 0%, 100% { transform: scale(1); }\n 50% { transform: scale(1.1); }\n}\n.badge { animation: pulse 2s infinite; } Related properties: animation-delay, animation-iteration-count, animation-direction, animation-fill-mode. Respect users who prefer less motion: > @media (prefers-reduced-motion: reduce) {\n * { animation: none !important; transition: none !important; }\n} ### 7.8 Tooltips > .tip { position: relative; }\n.tip .tip-text {\n visibility: hidden;\n position: absolute;\n bottom: 125%; left: 50%;\n transform: translateX(-50%);\n background: #333; color: white;\n padding: 6px 10px; border-radius: 4px;\n}\n.tip:hover .tip-text { visibility: visible; } ### 7.9 Image styling > img.avatar {\n width: 120px; height: 120px;\n object-fit: cover; /* fill the box without distortion */\n object-position: top; /* choose which part stays visible */\n border-radius: 50%;\n filter: grayscale(100%); /* blur(), brightness(), contrast(), sepia() */\n}\nimg.avatar:hover { filter: none; } Other image techniques include hover overlays, image modals (lightbox), centering images, shapes with shape-outside, and masking with mask-image. ### 7.10 Buttons, pagination, columns and user interface > .btn-group .btn { float: left; border: 1px solid #fff; }\n.pagination a { padding: 8px 14px; border: 1px solid #ddd; }\n.pagination a.active { background: #0066cc; color: white; }\n\n.article { column-count: 3; column-gap: 30px; column-rule: 1px solid #ddd; }\n\ntextarea { resize: vertical; }\n.card { cursor: pointer; } ### Practice and checkpoint Practice: build a pricing section with three cards. Add a gradient header on each, a soft shadow, a hover lift using transform and transition, and a fade-in animation when the page loads. Add one tooltip and one circular avatar. Checkpoint: 1. What is the difference between a transition and an animation? 2. Why prefer transform over top or left for animating movement? 3. What does object-fit: cover do? 4. How do you respect users who ask for reduced motion? Mini project: an animated portfolio landing page with a gradient hero, hover cards and a 3D flip card. ## Module 8: Flexbox and Grid (Week 8) ### Learning goals Lay out pages with Flexbox (one dimension) and Grid (two dimensions), and know which to choose. ### Part A, 8.1 Flex container Flexbox arranges items in a row or column, handles spacing and alignment, and lets items grow and shrink to fit. > .container {\n display: flex;\n flex-direction: row; /* row, row-reverse, column, column-reverse */\n flex-wrap: wrap; /* let items drop to the next line */\n justify-content: space-between; /* main axis: flex-start, center, flex-end, space-around, space-evenly */\n align-items: center; /* cross axis: stretch, flex-start, center, flex-end */\n gap: 20px;\n} Think of two axes. justify-content works along the main axis (the direction of the row or column). align-items works along the cross axis. If you switch to flex-direction: column, the two swap roles. ### 8.2 Flex items > .item { flex: 1; } /* grow equally to share space */\n.sidebar { flex: 0 0 250px; } /* don't grow, don't shrink, 250px wide */\n.main { flex: 1; }\n.special { order: -1; align-self: flex-end; } flex is shorthand for flex-grow, flex-shrink and flex-basis. ### 8.3 Common Flexbox patterns > /* Perfect centering */\n.center { display: flex; justify-content: center; align-items: center; height: 100vh; }\n\n/* Navbar with logo left, links right */\nnav { display: flex; justify-content: space-between; align-items: center; }\n\n/* Responsive wrap: items at least 250px, filling the row */\n.cards { display: flex; flex-wrap: wrap; gap: 16px; }\n.cards .card { flex: 1 1 250px; } Flexbox pages become responsive by using flex-wrap and media queries to switch flex-direction from row to column on small screens. ### Part B, 8.4 Grid container and tracks Grid lays out rows and columns together, which makes whole-page layouts and card galleries easy. > .grid {\n display: grid;\n grid-template-columns: 200px 1fr 1fr; /* fixed, then two equal flexible columns */\n grid-template-rows: auto;\n gap: 20px;\n} The fr unit means a fraction of the free space. Use repeat() and minmax() to avoid repetition: > .gallery {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));\n gap: 16px;\n} This single rule creates a gallery that automatically adjusts the number of columns to the available width, with no media query. ### 8.5 Alignment in Grid > .grid { justify-content: center; align-content: center; justify-items: stretch; align-items: start; } ### 8.6 Grid items and named areas > .hero { grid-column: 1 / 4; } /* span from line 1 to line 4 */\n.feature { grid-column: span 2; grid-row: span 2; }\n\n.layout {\n display: grid;\n grid-template-areas:\n "header header"\n "sidebar main"\n "footer footer";\n grid-template-columns: 250px 1fr;\n gap: 16px;\n}\nheader { grid-area: header; }\n.sidebar { grid-area: sidebar; }\nmain { grid-area: main; }\nfooter { grid-area: footer; } Named areas read almost like a drawing of your page, which makes them easy to understand and to rearrange for mobile. ### 8.7 The 12-column layout Many frameworks use a 12-column grid because 12 divides evenly by 2, 3, 4 and 6. > .row { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }\n.col-4 { grid-column: span 4; }\n.col-8 { grid-column: span 8; } ### 8.8 @supports The @supports rule applies styles only if the browser understands a feature, which is useful for fallbacks. > .layout { float: left; }\n@supports (display: grid) {\n .layout { display: grid; float: none; }\n} ### Flexbox or Grid? Use Flexbox when laying out in one direction (a row of buttons, a navbar), when content size should decide the layout, and for centering and spacing items. Use Grid when laying out rows and columns together (page layout, gallery), when the layout should decide where content goes, and for overlapping or precisely placing items. They work together: use Grid for the page, Flexbox inside components. ### Practice and checkpoint Practice: rebuild your Module 6 website shell: Grid for the overall page (header, sidebar, main, footer), Flexbox for the navbar and for a row of feature cards, and an auto-fit Grid for a photo gallery. Checkpoint: 1. What is the difference between justify-content and align-items? 2. What does flex: 1 do? 3. What does repeat(auto-fit, minmax(220px, 1fr)) produce? 4. When would you choose Grid over Flexbox? Mini project: a blog homepage with a Grid page layout and Flexbox cards. ## Module 9: Responsive web design (Week 9) ### Learning goals Make a page work on phones, tablets and desktops using the viewport tag, flexible units, media queries and fluid media. ### 9.1 What responsive design means A responsive page adapts its layout to the screen it is shown on, from a 360px phone to a 1920px monitor, without separate websites. It rests on three ideas: flexible layouts (percentages, fr, max-width), flexible media (images that scale), and media queries (rules that apply at certain screen sizes). ### 9.2 The viewport meta tag Without this line in the HTML head, phones pretend to be a wide desktop screen and shrink everything: >
Avoid fixed widths wider than the screen and avoid forcing horizontal scrolling. ### 9.3 Media queries > /* Mobile-first: base styles are for phones */\n.container { padding: 16px; }\n.cards { display: grid; grid-template-columns: 1fr; gap: 16px; }\n\n/* Tablets and up */\n@media (min-width: 768px) {\n .cards { grid-template-columns: repeat(2, 1fr); }\n}\n\n/* Laptops and up */\n@media (min-width: 1024px) {\n .container { max-width: 1100px; margin: 0 auto; }\n .cards { grid-template-columns: repeat(3, 1fr); }\n} Mobile-first means you write the small-screen styles first and use min-width queries to add complexity for bigger screens. It is easier to maintain than the reverse. !Common breakpoints (guides, not rules): 480px phones, 768px tablets, 1024px laptops, 1280px desktops. Better still, add a breakpoint where your design starts to break. Media queries can test more than width: > @media (orientation: landscape) { }\n@media (prefers-color-scheme: dark) { body { background: #111; color: #eee; } }\n@media print { nav, footer { display: none; } } ### 9.4 Responsive layouts: a navigation example > .nav { display: flex; flex-direction: column; } /* stacked on phones */\n@media (min-width: 768px) {\n .nav { flex-direction: row; justify-content: space-between; }\n} ### 9.5 Responsive images and video > img, video {\n max-width: 100%;\n height: auto;\n}\n\n.video-wrap { position: relative; aspect-ratio: 16 / 9; }\n.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; } In HTML, srcset and picture let the browser choose a smaller file on small screens, which saves data: >
### 9.6 Responsive typography > html { font-size: 100%; }\nh1 { font-size: clamp(1.75rem, 4vw + 1rem, 3rem); } /* min, preferred, max */ ### 9.7 Frameworks and templates Frameworks such as Bootstrap and W3.CSS provide ready-made responsive grids and components. They are a good shortcut once you understand the fundamentals in this course; without those, they feel like magic. Free responsive templates can also be studied and modified as learning material. ### 9.8 Testing In Chrome DevTools, press F12, then the device toolbar icon to preview phones and tablets. Drag the window narrower and look for overflowing text, tiny tap targets and horizontal scrolling. Test on a real phone when possible. ### Practice and checkpoint Practice: take your Module 8 blog homepage and make it mobile-first: one column on phones, two on tablets, three on laptops. Add the viewport tag, make images fluid, and switch the navbar from stacked to horizontal at 768px. Checkpoint: 1. What happens on a phone if the viewport meta tag is missing? 2. What does mobile-first mean in terms of min-width and max-width? 3. Why set max-width: 100% and height: auto on images? 4. What does clamp(1rem, 2.5vw, 2rem) do? Mini project: make your portfolio or website shell fully responsive and test it at 360px, 768px and 1280px. ## Modules 10 and 11: Modern CSS and Capstone (Week 10) ### Outline from the schedule Week 10 covers these topics: Variables, @property, Math Functions, Box Sizing, @supports, Optimization, Accessibility and Sass, followed by the Module 11 capstone. The lesson text for these was not included in the material, so each topic below is a placeholder to expand. !Add your lesson notes here using Teacher mode. Module 5 to 9 already introduce box-sizing, @supports, clamp() and reduced-motion, so link back to those lessons. ### Variables and @property Placeholder for the Week 10 lesson on CSS variables and @property. ### Math functions and Box Sizing Placeholder. Related earlier lessons: clamp() in Module 9 and box-sizing: border-box in Module 2. ### @supports, Optimization and Accessibility Placeholder. Related earlier lessons: @supports in Module 8 and focus styles and reduced motion in Modules 6 and 7. ### Sass Placeholder for the Sass introduction. The SCSS and Sass courses on this platform can be linked from here. ### Module 11: Capstone project Placeholder. Each module's mini project builds toward the final capstone: for example the Module 6 website shell, Module 8 blog homepage and Module 9 responsive portfolio can be combined into one final site.