Aral Code

CSS Tutorial

CSS (Cascading Style Sheets) is the language that makes web pages look good. HTML decides what is on the page; CSS decides how it looks: the colors, fonts, spacing, and layout, and how the page changes on a small phone screen versus a wide laptop.

This free course has 33 short lessons. Each one teaches one idea with examples you can edit live, a list of common mistakes, a Taglish summary and a quick quiz.

Before you start

You should already know basic HTML: elements, attributes, classes and ids. If not, take the HTML Tutorial first, at least up to the Class and Id lesson. CSS makes much more sense once you can write a simple page.

What you'll be able to do

  • Change colors, backgrounds, fonts and spacing with confidence
  • Understand the box model, the idea behind every layout
  • Build modern layouts with Flexbox and CSS Grid
  • Make pages that look good on phones, tablets and laptops
  • Add hover effects, transitions and simple animations
  • Style a complete page for a small business, from scratch

All lessons

Getting Started

  1. What Is CSS? An Introduction for BeginnersLearn what CSS is, what it does to an HTML page, and see the same page before and after CSS — your first step to designing websites.
  2. CSS Syntax — Selectors, Properties, Values and CommentsLearn how to read and write a CSS rule — selector, curly braces, property, colon, value and semicolon — plus how to write comments.
  3. How to Add CSS — Inline, Internal and External Style SheetsThe three ways to add CSS to an HTML page — inline styles, the style element, and an external .css file — and when to use each one.
  4. CSS Selectors — Element, Class, Id, Group and DescendantLearn how to pick exactly the elements you want to style using element, class, id, universal, group, descendant and child selectors.

Colors & the Box Model

  1. CSS Colors — Names, HEX, RGB, HSL and OpacityColor text and backgrounds with CSS using color names, HEX, RGB and HSL, add transparency, and build a simple color palette for your website.
  2. CSS Backgrounds — Colors, Images, Size and PositionAdd background colors and images with CSS, control repeat, size and position, and build a hero banner with text over an image.
  3. CSS Borders and Rounded CornersDraw borders around elements with CSS — width, style and color — style each side separately, and make rounded corners and circles with border-radius.
  4. CSS Margin and Padding — Spacing Made SimpleUnderstand the difference between padding (space inside) and margin (space outside), use the 1-, 2-, 3- and 4-value shorthands, and center a box with margin auto.
  5. The CSS Box Model, Width, Height and box-sizingEvery element is a box. Learn the four layers of the CSS box model, how width and height are calculated, and why box-sizing border-box makes layouts easier.

Text & Content

  1. CSS Text — Alignment, Decoration, Spacing and TransformStyle text with CSS — align it, underline or remove underlines, change letter case, and adjust line height and letter spacing for easy reading.
  2. CSS Fonts — Family, Size, Weight and Google FontsChoose fonts with font-family and fallbacks, set sizes and weights, use the font shorthand, and add free Google Fonts to your website.
  3. CSS Units — px, %, em, rem, vw and vh ExplainedUnderstand absolute and relative CSS units — pixels, percentages, em, rem, viewport units — and learn which one to use for fonts, spacing and layout.
  4. Styling Links and Buttons with CSSStyle links in all their states — link, visited, hover, focus and active — and turn links into good-looking, accessible buttons and navigation menus.
  5. Styling Lists with CSS — Bullets, Numbers and MenusChange list bullets and numbering, use custom markers and emojis, remove bullets for menus, and build a styled checklist with CSS.
  6. Styling Tables with CSSTurn plain HTML tables into clean, readable data tables — borders, border-collapse, padding, zebra stripes, hover rows and mobile-friendly scrolling.

Layout

  1. CSS Display — block, inline, inline-block and noneThe display property decides how an element sits on the page. Learn block, inline, inline-block and none, plus the difference between display none and visibility hidden.
  2. CSS Position — relative, absolute, fixed and stickyMove elements out of the normal flow with the position property — relative, absolute, fixed and sticky — and control stacking with z-index.
  3. CSS Overflow, Float and Object-fitControl content that doesn't fit with overflow, wrap text around images with float, and crop images neatly with object-fit.
  4. CSS Flexbox — The Flex ContainerLearn Flexbox, the easiest way to line things up in a row or column — display flex, flex-direction, justify-content, align-items, gap and flex-wrap.
  5. CSS Flexbox — Flex Items, flex-grow and Real LayoutsControl individual flex items with flex-grow, flex-shrink, flex-basis, the flex shorthand, align-self and order, then build cards, a sidebar layout and a sticky footer.
  6. CSS Grid — Rows, Columns and the fr UnitBuild two-dimensional layouts with CSS Grid — grid-template-columns, the fr unit, repeat(), gap, and responsive galleries with auto-fit and minmax.
  7. CSS Grid Template Areas — Drawing Page LayoutsName the parts of your page and "draw" the layout with grid-template-areas, align grid items, and build a complete responsive page layout.

Responsive Design

  1. CSS Media Queries — Different Styles for Phones and LaptopsUse media queries to change your layout at different screen sizes, choose sensible breakpoints, and support dark mode and printing.
  2. Responsive Web Design — Images, Typography and TestingPut it all together — fluid containers, responsive images, fluid font sizes with clamp(), touch-friendly design and how to test your site on many screen sizes.

Selectors & the Cascade

  1. CSS Pseudo-classes — :hover, :focus, :nth-child and MoreStyle elements based on their state or position — hover, focus, checked, first-child, nth-child, not, and form validation states like valid and invalid.
  2. CSS Pseudo-elements — ::before, ::after and MoreAdd decorative content with ::before and ::after, style the first letter and line, the placeholder and text selection, and learn the sibling combinators + and ~.
  3. CSS Specificity, the Cascade and InheritanceFind out why a style "doesn't work" — how the cascade decides which rule wins, how specificity is counted, how inheritance works, and why to avoid !important.
  4. CSS Variables (Custom Properties) and calc()Store colors, sizes and spacing in CSS variables, reuse them everywhere, build a light and dark theme, and do math with calc().

Effects & Animation

  1. CSS Gradients and ShadowsCreate smooth color blends with linear, radial and conic gradients, and add depth with box-shadow and text-shadow — without any image files.
  2. CSS Transforms and TransitionsMove, rotate, scale and skew elements with transform, and make style changes happen smoothly with transition — perfect for hover effects.
  3. CSS Animations with @keyframesCreate animations that play on their own with @keyframes — loading spinners, pulses, fades and a jeepney driving across the screen — and respect reduced-motion settings.

Going Further

  1. Styling Forms with CSSMake forms clean and easy to use — style inputs, labels, focus states, buttons, checkboxes and select menus, and lay out a mobile-friendly registration form.
  2. CSS Final Project — Style a Small Business WebsiteUse everything from the course to style a complete one-page website for a local business — header, hero, menu cards, about section, contact and footer — step by step.

Keep a reference handy

The CSS Property List lists the properties used in this course, with a short explanation of each and the lesson that teaches it.