The Blue Cup now has structure: the page is centred, the sections have room to breathe and the booking card looks like a block. But the text still uses the browser's default typography, the footer doesn't stand out from the content, the booking form is a succession of small, misaligned fields, and the brand colours are repeated as hexadecimal values throughout the stylesheet. In this lesson you'll work through the properties used to style the most common elements on a page: typography, colour and background, text properties, lists, links and buttons, forms, images and rounded corners. Before you start, you'll learn to store the palette in CSS variables, so that the whole design depends on a single place. By the end, The Blue Cup will have a consistent stylesheet, with a recognisable visual identity on every page.
Contents
- A palette with CSS variables
- Typography:
font-familyand font stacks - Text size, line height and weight
- Colour and background
- Text properties
- Lists
- Links and buttons
- Forms
- Images
- Rounded corners
- Project: The Blue Cup's visual identity
A palette with CSS variables
The Blue Cup's palette was set in Styling Tables: #1f4e79 (brand blue), #c8d3e0 (borders), #dce6f0 (light blue), #fff6e0 (cream) and #f7f7f7 (light grey). Right now, #1f4e79 appears more than ten times in the stylesheet. If the owner decides on a slightly lighter blue, you'd have to find and change every occurrence without missing any.
CSS custom properties, known as CSS variables, solve the problem: you define the value once, with a name, and use it everywhere.
:root {
--color-brand: #1f4e79;
--color-border: #c8d3e0;
}
caption {
color: var(--color-brand);
}
th, td {
border: 1px solid var(--color-border);
}- Declaring: the name starts with two hyphens (
--color-brand) and is written like any other property. It's case-sensitive, so in the project they'll always be lowercase with hyphens, like the classes. :rootis a pseudo-class that selects the root of the document, thehtmlelement. Variables declared there are inherited and available throughout the page.- Using: the
var()function replaces the name with its value.var(--color-brand)is#1f4e79. - Fallback value:
var(--color-brand, #1f4e79)uses the second value if the variable doesn't exist. Useful in components that get copied into other projects; in your own stylesheet it's rarely needed.
Advantages:
| Without variables | With variables |
|---|---|
#1f4e79 repeated in many rules |
A single place: --color-brand |
| Changing the colour means find and replace | You change one line |
#c8d3e0 doesn't say what it's for |
--color-border explains its role |
Risk of near-identical shades by mistake (#1f4e78) |
Everything uses exactly the same value |
Name variables after their role (--color-brand, --color-border, --color-text), not their appearance (--dark-blue): if tomorrow the brand becomes green, --color-brand: #2e6b30 still makes sense; --dark-blue: #2e6b30 doesn't. It's the same rule you follow with classes.
Variables can store any value, not just colours: font stacks, measurements, border radii.
Typography: font-family and font stacks
font-family sets the typeface of the text. Since you don't know which fonts each visitor has installed, you write a font stack: a list of options in order of preference, separated by commas. The browser uses the first one it finds.
body {
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}| Part of the stack | What it is |
|---|---|
system-ui |
The typeface of the user's operating system interface |
-apple-system, "Segoe UI", Roboto |
The system fonts on macOS/iOS, Windows and Android, for older browsers that don't understand system-ui |
"Helvetica Neue", Arial |
Widely available sans-serif fonts, as a fallback |
sans-serif |
A generic family: "any sans-serif font". Always last, as the final guarantee |
A few rules:
- Names with spaces go in quotes:
"Segoe UI". Generic families (serif,sans-serif,monospace) go without quotes: they're keywords. - A system font stack is fast (nothing is downloaded), readable and looks natural on every device.
- For The Blue Cup's headings you'll use a serif font (
serif), which gives a more classic, handcrafted feel:Georgia, "Times New Roman", Times, serif.
Web fonts: you can also download fonts from your server with the
@font-facerule or from services such as Google Fonts. They add personality, but they add downloads too (you'll see this in Performance and Resource Loading) and, if they're loaded from a third-party server, they send the visitor's IP address to that service, which has data protection implications in the European Union. If you use them, host them on your own server. The Blue Cup sticks with system fonts.
Text size, line height and weight
font-size in rem
By default the browser uses a size of 16 pixels for text, and the user can change it in their settings. If you write sizes in rem (relative to that root size), you respect their preference:
h1 { font-size: 2.25rem; } /* 36 px with the default settings */
h2 { font-size: 1.75rem; } /* 28 px */
h3 { font-size: 1.375rem; } /* 22 px */
small { font-size: 0.875rem; } /* 14 px */Don't change the size of html or body with pixels: you'd override the user's preference. Body text at 1rem (16 px) is a good starting point.
line-height
Line height is the height of each line. The default value (around 1.2) feels cramped for reading paragraphs. For running text, between 1.5 and 1.7 is much more comfortable:
Write it without a unit: 1.6 means "1.6 times the font size of each element", and it's recalculated for each one. With a unit (1.6em), it would be calculated once on the body and the large headings would inherit a line height of 25.6 px, too small for them, and their lines would overlap.
font-weight and font-style
| Property | Common values | Use |
|---|---|---|
font-weight |
normal (400), bold (700), or numbers from 100 to 900 |
Stroke thickness |
font-style |
normal, italic |
Italics |
Remember the lesson Text Formatting Tags: strong and em have meaning (importance, emphasis) and the browser makes them bold and italic by default. With CSS you only change the appearance: you can remove the bold from the product names on the menu (as you did) without changing what they are.
Colour and background
| Property | What it colours | Inherited? |
|---|---|---|
color |
The text (and, by default, borders and anything using currentColor) |
Yes |
background-color |
The box's background, including the padding | No |
Colour formats you already know: hexadecimal (#1f4e79), rgba() with transparency (the zebra rows) and keywords (white, transparent). In the project, they'll all come from the variables.
Contrast isn't optional. Light grey text on white may look elegant on your screen and be unreadable in sunlight, on a cheap screen or for someone with low vision. The accessibility guidelines (WCAG) require a minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text and for the borders of controls (such as the border of a form field). DevTools shows the contrast when you inspect a colour in the Styles pane. The Blue Cup's palette passes comfortably: brand blue on white, and white on brand blue, exceed 8.5:1 (about 8.66:1). You'll study this in depth in Web Accessibility Basics.
A practical consequence: #c8d3e0 is fine for separating cells, but not as the border of a form field, because its contrast with white doesn't reach 3:1. For the fields you'll use a dark grey.
Text properties
| Property | Values | Example of use |
|---|---|---|
text-align |
left, right, center, justify |
Prices on the right; running text on the left |
text-decoration |
none, underline, line-through, and styles such as underline dotted |
Removing the underline from the menu; dotted underline on abbr |
text-underline-offset |
A measurement | Moving the underline away from the text so it doesn't cut through letters with descenders |
text-transform |
uppercase, lowercase, capitalize |
The menu categories in capitals |
letter-spacing |
A measurement | A little space between letters in capitals |
Two recommendations:
- Avoid
text-align: justifyon the web: without hyphenation, it leaves "rivers" of white space between words, which make reading harder (especially for people with dyslexia). - Don't type in capitals in the HTML to achieve an effect: use
text-transform, as you already did on the menu. The content stays correct and screen readers don't spell out words in capitals as if they were acronyms.
Lists
Lists have bullets or numbers (the markers) and a left indent that the browser applies with padding-left.
| Property | Values | Effect |
|---|---|---|
list-style-type |
disc, circle, square, decimal, lower-alpha, none… |
Marker type |
list-style-position |
outside (default), inside |
Marker outside or inside the li box |
list-style |
Shorthand | list-style: none removes the markers |
The ::marker pseudo-element selects the marker of each list item. With this rule, the bullets and numbers across the whole site take on the brand blue without changing the colour of the text.
When a list is used for something that isn't presented as a list (the menu, the product gallery), its markers and indent are removed:
The list is still a list in the HTML and for screen readers ("list, 3 items"). Be aware of one detail: Safari stops announcing a ul with list-style: none as a list. If that matters in a particular case, it can be reinforced with role="list" on the ul (you'll see this in Using ARIA Roles and Attributes).
Links and buttons
Links
You already gave them colour and states in Basic CSS Selectors. Two common tweaks:
- Keep the underline on links within text: it's the clearest hint that something is a link, and it doesn't depend on telling colours apart. In areas where the context already makes it clear (the menu, a card) it can be removed.
- When a link sits on a dark background, like the footer you're about to paint blue, it needs its own colours for all its states. Remember that
a:visited(0, 1, 1) beats selectors such asbody > footer a(0, 0, 3): you'll have to include the visited state explicitly.
Buttons
Buttons (button) look like the operating system's by default. To integrate them into the design:
button {
padding: 0.6em 1.25em;
border: 2px solid var(--color-brand);
border-radius: var(--radius);
background-color: var(--color-brand);
color: var(--color-white);
font-weight: bold;
cursor: pointer;
}
button:hover {
background-color: var(--color-white);
color: var(--color-brand);
}- Padding in
emmakes the button grow with its text. cursor: pointershows the hand on hover, as with links.- On
:hoverthe colours are inverted. The border, in the same blue, keeps the button the same size and stops it from "jumping".
A link that looks like a button is still a link, and a button that looks like a link is still a button. The rule from Creating Hyperlinks doesn't change: if it takes you to another page, a; if it performs an action (submitting, opening a dialog), button. CSS only changes the appearance.
Forms
Form controls have three quirks worth knowing about:
- They don't inherit the page's typography: they use the system's own font and size, usually smaller. This is fixed with
font: inherit, a shorthand that copies all the font properties from the parent element. - Many are
inline-block: they sit on the same line as theirlabel, and the width depends on the browser. - Some (checkboxes, radio buttons, drop-down lists) have parts drawn by the operating system that can only be partly customised.
Guidelines for a readable form:
- Label above the field: easier to scan by eye and to adapt to narrow screens.
- Wide fields with padding, with a reasonable maximum width for the data they expect.
- A border with enough contrast (3:1 at least) so that it's clear where to type.
- Very visible focus: you already have it with
:focus-visible. - Hints in a softer tone, just below the field.
input[type="text"],
input[type="email"],
select,
textarea {
display: block;
width: 100%;
max-width: 24rem;
padding: 0.5rem;
border: 1px solid var(--color-text-muted);
border-radius: var(--radius);
}display: blockputs each field on its own line, below its label.width: 100%withmax-width: 24rem: the field takes up the available width, up to a maximum. Thanks tobox-sizing: border-box, the padding and border don't make it stick out.- The list of
inputtypes is written out by hand with attribute selectors: that way it doesn't affect checkboxes, radio buttons or hidden fields, which should keep their shape.
Images
An image with width="800" is displayed at 800 pixels even if its container is narrower, and it sticks out of it. The most widespread base rule prevents this:
max-width: 100%: the image is never wider than its container; if it fits, it's shown at its own size.height: auto: when it narrows, the height is recalculated to keep the proportions. Without this, theheight="600"attribute would leave it distorted.- The HTML
widthandheightattributes are still necessary: the browser uses them to calculate the aspect ratio and reserve the space before downloading the image.
This is only the first step: choosing different versions of an image according to the screen is the subject of Responsive Images and Videos.
Rounded corners
border-radius rounds the corners of a box, whether or not it has a visible border (the background is clipped too):
| Value | Effect |
|---|---|
border-radius: 0.5rem; |
All four corners with the same radius |
border-radius: 0 0.5rem 0.5rem 0; |
Corner by corner, starting at the top left and going clockwise |
border-radius: 50%; |
On a square box, a circle (useful for avatars) |
A small, constant radius across the whole site (buttons, fields, cards) gives visual consistency. That's why it will go in a variable: --radius.
Project: The Blue Cup's visual identity
You're going to complete the stylesheet section by section. Rules that already existed are shown when they change; everything else stays as it is.
- Variables (section 1)
/* ---------- 1. Variables ---------- */
:root {
/* Brand palette */
--color-brand: #1f4e79;
--color-border: #c8d3e0;
--color-soft: #dce6f0;
--color-cream: #fff6e0;
--color-light-grey: #f7f7f7;
/* Text */
--color-text: #222222;
--color-text-muted: #555555;
--color-visited: #5b3f86;
--color-white: #ffffff;
/* Typography */
--font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
--font-headings: Georgia, "Times New Roman", Times, serif;
/* Shapes */
--radius: 0.5rem;
}
- Replace the values with variables
With styles.css open, use VS Code's Replace (Ctrl + H), in this file only and from section 2 onwards (don't replace the lines in :root, or the variable would be defined in terms of itself and would stop working):
| Find | Replace with |
|---|---|
#1f4e79 |
var(--color-brand) |
#c8d3e0 |
var(--color-border) |
#dce6f0 |
var(--color-soft) |
#fff6e0 |
var(--color-cream) |
#f7f7f7 |
var(--color-light-grey) |
#5b3f86 |
var(--color-visited) |
#ffffff |
var(--color-white) |
Use the Replace button (one at a time) rather than Replace All, so you can skip the ones in :root. The colour of the zebra rows, rgba(31, 78, 121, 0.06), stays as it is: it's the brand blue with transparency, and basic CSS doesn't let you add transparency to a hexadecimal variable. Leave it with a comment:
Reload the pages: everything should look exactly the same. If anything loses its colour, check in the Styles pane that the variable is spelt correctly (unknown names are flagged).
- Base (section 2)
Extend the body rule and add html and images:
html {
background-color: var(--color-light-grey);
}
body {
max-width: 64rem;
margin: 0 auto;
font-family: var(--font-body);
line-height: 1.6;
color: var(--color-text);
background-color: var(--color-white);
}
img,
video {
max-width: 100%;
height: auto;
}- The light grey background on
htmlframes the white column of thebodyon wide screens: the page looks like a sheet of paper on a table. - The font, line height and text colour are set just once on the
bodyand reach the whole page through inheritance.
- Typography and links (section 3)
The complete section now looks like this:
/* ---------- 3. Typography and links ---------- */
h1,
h2,
h3 {
font-family: var(--font-headings);
line-height: 1.2;
color: var(--color-brand);
}
h1 {
font-size: 2.25rem;
}
h2 {
font-size: 1.75rem;
}
h3 {
font-size: 1.375rem;
}
small {
font-size: 0.875rem;
}
figcaption {
margin-top: 0.5rem;
font-size: 0.875rem;
color: var(--color-text-muted);
}
li::marker {
color: var(--color-brand);
}
.old-price {
color: var(--color-text-muted);
}
.featured .price {
font-size: 1.5rem;
color: var(--color-brand);
}
a {
color: var(--color-brand);
text-underline-offset: 0.15em;
}
a:visited {
color: var(--color-visited);
}
a:hover {
background-color: var(--color-cream);
}
abbr[title] {
text-decoration: underline dotted;
cursor: help;
}- The headings use the serif font and the brand blue, with a tighter line height.
figcaption, in small grey text, works for the gallery, the storefront and the video..old-price(the struck-through "€4.20" in the offer) is shown in grey, and.featured .pricemakes the new price large. The descendant selector avoids affecting the.pricecells on the menu.
- Components (section 6)
Update the card and the reviews, and add the quotation captions:
.card,
.card:visited {
color: var(--color-text);
}
.card {
display: block;
max-width: 32rem;
padding: 1.5rem;
border: 2px solid var(--color-brand);
border-radius: var(--radius);
background-color: var(--color-soft);
text-decoration: none;
}
/* .card h2 and .card p, unchanged */
.featured {
padding: 1rem 1.5rem;
border-left: 6px solid var(--color-brand);
border-radius: 0 var(--radius) var(--radius) 0;
background-color: var(--color-cream);
}
.review {
padding: 1rem 1.5rem;
border: 1px solid var(--color-border);
border-radius: var(--radius);
}
.review blockquote {
margin: 0 0 0.75rem;
font-style: italic;
}
.review figcaption {
margin-top: 0;
font-weight: bold;
}.card:visited(0, 2, 0) beatsa:visited(0, 1, 1): the card's text doesn't turn violet after you've visited the bookings page.- The offer rounds only its right-hand corners: the blue bar is on the left.
- The reviews are in italics, with the reviewer's name in bold.
- The footer (section 5)
Replace the body > footer rule and add the rules for its links:
body > footer {
padding: 2rem;
background-color: var(--color-brand);
color: var(--color-white);
}
body > footer a,
body > footer a:visited {
color: var(--color-white);
}
body > footer a:hover {
background-color: var(--color-white);
color: var(--color-brand);
}
body > footer :focus-visible {
outline-color: var(--color-white);
}- The footer becomes a blue band with white text. The top line is no longer needed.
- The SVG cup icon uses
currentColor, as you decided in Graphics in HTML: SVG and canvas: it's now drawn in white without touching the SVG. - The footer links, visited or not, are white; on hover, the colours are inverted (the general cream wouldn't be readable with white text).
- The blue focus outline would be invisible on the blue background: in the footer it turns white. Only the colour changes; the thickness and style come from the base rule.
- Forms and buttons (section 8)
/* ---------- 8. Forms and buttons ---------- */
input,
select,
textarea,
button {
font: inherit;
}
fieldset {
margin: 0 0 1.5rem;
padding: 1rem 1.5rem;
border: 1px solid var(--color-border);
border-radius: var(--radius);
}
legend {
padding: 0 0.5rem;
font-weight: bold;
color: var(--color-brand);
}
fieldset fieldset {
margin-bottom: 1rem;
padding: 0;
border: none;
}
fieldset fieldset legend {
padding: 0;
color: var(--color-text);
}
label {
font-weight: bold;
}
input[type="radio"] + label,
input[type="checkbox"] + label {
margin-right: 1rem;
font-weight: normal;
}
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="search"],
select,
textarea {
display: block;
width: 100%;
max-width: 24rem;
margin-top: 0.25rem;
padding: 0.5rem;
border: 1px solid var(--color-text-muted);
border-radius: var(--radius);
background-color: var(--color-white);
color: var(--color-text);
}
textarea {
max-width: 36rem;
}
input:focus,
select:focus,
textarea:focus {
border-color: var(--color-brand);
}
form small {
display: block;
margin-top: 0.25rem;
color: var(--color-text-muted);
}
button {
padding: 0.6em 1.25em;
border: 2px solid var(--color-brand);
border-radius: var(--radius);
background-color: var(--color-brand);
color: var(--color-white);
font-weight: bold;
cursor: pointer;
}
button:hover {
background-color: var(--color-white);
color: var(--color-brand);
}
button[type="button"] {
background-color: var(--color-white);
color: var(--color-brand);
}
button[type="button"]:hover {
background-color: var(--color-soft);
}The key points:
font: inheritmakes fields and buttons use the site's typography.- The main
fieldsetelements ("Your details", "Your booking", "Preferences") are cards with a soft border and theirlegendin blue. The nested ones (the radio button groups) lose their border: a box inside another box would clutter the form.fieldset fieldsetis a descendant selector that only affects the nested ones. input[type="radio"] + labeluses the adjacent sibling combinator: the label immediately after a radio button or checkbox loses its bold and gets a right margin, to separate the options.form smalldisplays the hints as blocks, below the field and in grey.button[type="button"](the "See booking conditions" button, which opens thedialog) is presented as a secondary button: white with blue text. The form's submit button and the dialog's "Got it" are primary, blue buttons.
- Adjust the form's HTML
Previously, the small hints needed a <br> in front of them to drop onto a new line, and the comments label needed another after it to separate the textarea. Now form small and the fields are blocks: those line breaks are presentation written into the HTML, and they're no longer needed. In bookings.html, remove the <br> elements in those cases:
<p>
<label for="time">Time *</label>
<input type="time" id="time" name="time" required min="08:00" max="19:00" step="1800">
<small>From 8:00 to 19:00, on the hour or half past.</small>
</p>
…
<p>
<label for="comments">Comments (allergies, highchairs…)</label>
<textarea id="comments" name="comments" rows="4" cols="40" maxlength="500"></textarea>
<small>500 characters maximum.</small>
</p>Do the same for the phone number and the number of guests, and check the forms in contact.html and news.html in case they have similar line breaks. It's a good example of separating content and presentation: the HTML says "this is a hint for the field", and the CSS decides that it's displayed underneath.
- Gallery (section 9)
/* ---------- 9. Gallery ---------- */
.product-gallery {
list-style: none;
padding-left: 0;
}
.product-gallery figure {
padding: 0.75rem;
border: 1px solid var(--color-border);
border-radius: var(--radius);
background-color: var(--color-light-grey);
}
.product-gallery img {
display: block;
border-radius: var(--radius);
}
.product-gallery figcaption {
font-size: 1rem;
color: var(--color-text);
}Each product is now a tile with a rounded-corner photo and the name and price underneath, at a readable size (more prominent than a normal caption, because here the name and price are the main information). For now the tiles are stacked one below the other; you'll arrange them in a grid in the next lesson.
- Check it
- Go through all seven pages. They all share the typography, the blue serif headings, the blue footer with the cup icon in white and the grey background around the column.
- In
bookings.html, tab through the form: each field shows the focus outline and the blue border. The hints appear in grey under each field. Open the booking conditions: the secondary button and the dialog's "Got it" are clearly different. - In DevTools, select a paragraph and look for the
body'scolorin the Styles pane. Hover overvar(--color-text): you'll see the real value. - Experiment: in
:root, change--color-brandto#2e6b30(green). The whole site changes colour with a single line. Undo the change. - Check a contrast ratio: inspect the text of a
figcaptionand click the colour swatch in the Styles pane; the colour picker shows the contrast ratio.
Common Mistakes and Tips
- Writing the variable without the two hyphens (
var(color-brand)) or with a different name (--color-Brand): the declaration isn't valid and the property falls back to its inherited or default value, without warning. - Also replacing the values in
:rootwhen switching to variables:--color-brand: var(--color-brand)is a circular reference and the variable stops working. - Font stacks without a generic family at the end: if none of the fonts is available, the browser uses its default font, which may be a serif.
- Font sizes in pixels on
htmlorbody: they stop the user from enlarging text through the browser settings. line-heightwith a unit on thebody: large headings inherit a fixed height and their lines overlap.- Field borders with poor contrast: the field "disappears" for many people.
- Forgetting
font: inheriton controls: the form looks as if it belongs to another site. - Removing the underline from every link in the text: colour alone isn't enough to recognise them.
- Link colours on dark backgrounds without the
:visitedstate: visited links appear in an unreadable colour. - Tip: when you're asked for a design change ("make the borders rounder"), first look for a variable. If there isn't one and the value is repeated, create it.
Exercises
Exercise 1. The owner wants to try out an "autumn mode" by changing just three things: the brand colour to #8a4b1c (brown), the cream to #fbe8d3 and more rounded borders (1rem). Write what you'd change in the stylesheet and explain why, with variables, that's all it takes. Is there anything that wouldn't change?
Exercise 2. Style the summary elements in the frequently asked questions on contact.html: in brand blue, bold, with 0.75rem of padding, a 1px bottom border in the border colour, and the hand cursor. When the details is open, the summary should have a light blue background. (Hint: the details element's open attribute.)
Exercise 3. A colleague wants a "button" on the home page that leads to the menu, but it looks like an ordinary link, underlined and with no background, and on hover it doesn't behave like the other buttons. Find the causes and fix them without changing the element:
Solutions
Solution 1. Changing three lines in :root is enough:
:root {
--color-brand: #8a4b1c;
--color-cream: #fbe8d3;
--radius: 1rem;
/* everything else, unchanged */
}Every rule that uses var(--color-brand), var(--color-cream) or var(--radius) changes at once: headings, links, menu, buttons, table headers, footer, cards, fields. What wouldn't change:
- The zebra rows, which use
rgba(31, 78, 121, 0.06)written by hand: they'd stay bluish. They'd have to be changed too. - The
theme-colorin thehead(#1f4e79) and the SVG favicon, which are in the HTML and in separate files: CSS doesn't reach them. - The colours of the
canvaschart, which are painted from JavaScript.
Before changing the brand you'd also need to check the contrast of the brown against white (it exceeds 4.5:1, but you should always measure it).
Solution 2.
summary {
padding: 0.75rem;
border-bottom: 1px solid var(--color-border);
color: var(--color-brand);
font-weight: bold;
cursor: pointer;
}
details[open] summary {
background-color: var(--color-soft);
}details[open] is an attribute selector that only matches when the details is expanded (the browser adds and removes the open attribute on click). Combined with the descendant summary, it changes the background of the open summary only. It would go in section 6, Components.
Solution 3. The element is a link (a), not a button: the button rule doesn't affect it at all, so it has no padding, no background and none of the buttons' :hover; only the general a styles. On top of that, the btn class has no rule. The solution is to create a class for links that look like buttons (or add it to the button selector group):
button,
.btn {
display: inline-block;
padding: 0.6em 1.25em;
border: 2px solid var(--color-brand);
border-radius: var(--radius);
background-color: var(--color-brand);
color: var(--color-white);
font-weight: bold;
text-decoration: none;
cursor: pointer;
}
.btn:visited {
color: var(--color-white);
}
button:hover,
.btn:hover {
background-color: var(--color-white);
color: var(--color-brand);
}display: inline-block is needed so that the link's vertical padding is respected (it's inline); text-decoration: none removes the underline; and .btn:visited prevents the violet. And it's still a link, because it leads to another page: choosing a was correct.
Conclusion
You've learnt how to style the most common elements on a page: storing the palette and other values in CSS variables with :root and var(), writing font stacks with a generic family at the end, using sizes in rem, unitless line heights and meaningful weights, handling color and background-color without forgetting contrast, and adjusting text with text-align, text-decoration and text-transform. You also know how to change list markers (or remove them without the lists ceasing to be lists), give links and buttons consistent states, make forms readable with font: inherit, labels above fields and well-contrasted borders, stop images from overflowing with max-width: 100% and round corners with border-radius. The Blue Cup now has a recognisable visual identity: blue serif headings, a blue footer with the icon in white, rounded cards and reviews, primary and secondary buttons, a clear booking form and a gallery of tiles with name and price. But the blocks are still placed according to normal flow: the logo above the menu, the gallery products one below the other and the home page offer between two sections, instead of beside the content. In the next lesson, Introduction to Layout with Flexbox and Grid, you'll learn CSS's two modern tools for placing boxes in rows, columns and grids, and give The Blue Cup its final desktop layout.
HTML Course
Module 1: Introduction to HTML
- What Is HTML?
- Setting Up Your Work Environment
- Basic Structure of an HTML Document
- Tags, Elements and Attributes
- Creating Your First HTML Page
- File Organisation and Paths
Module 2: Text Formatting in HTML
- Headings and Paragraphs
- Text Formatting Tags
- Lists: Ordered, Unordered and Description Lists
- Block Quotes and Preformatted Text
- Block and Inline Elements: div and span
Module 3: Links and Media in HTML
- Creating Hyperlinks
- Special Links: Anchors, Email, Phone and Downloads
- Adding Images
- Embedding Videos
- Using the Audio Element
Module 4: Tables in HTML
- Basic Table Structure
- Table Head, Body and Foot
- Merging Cells: colspan and rowspan
- Accessible Tables: caption, scope and headers
- Styling Tables
Module 5: Forms in HTML
- Creating a Basic Form
- Form Elements: input, textarea and select
- HTML5 Input Types
- Labels and Grouping: label, fieldset, legend and datalist
- Form Attributes and Validation
- Submitting Forms
Module 6: HTML5 Semantic Elements
- Introduction to Semantic HTML
- header, nav and footer
- article, section and aside
- main and figure
- Other Semantic Elements: time, address, details and dialog
Module 7: Advanced HTML Techniques
- HTML Entities
- Using iframes
- Data Attributes
- Metadata: meta, SEO and Open Graph
- Microdata and Structured Data
- Graphics in HTML: SVG and canvas
Module 8: Integrating HTML and CSS
- Linking CSS to HTML
- Inline, Internal and External CSS
- Basic CSS Selectors
- The Box Model
- Styling HTML Elements
- Introduction to Layout with Flexbox and Grid
Module 9: Responsive Web Design
Module 10: Best Practices and Accessibility
- HTML Best Practices
- Validating HTML Code
- Web Accessibility Basics
- Using ARIA Roles and Attributes
- Accessibility Testing
- Performance and Resource Loading
