Tsallaka zuwa abun ciki
Justice Tech School

CSS Tutorial

Colours, fonts and layout for your pages.

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