Topic guide
HTML & CSS Basics
You do not need to become a developer to change a headline, swap a photo or fix a broken layout. This is the small slice of HTML and CSS that covers most edits.
Many people end up with an HTML file they did not write: a template, a page from an AI assistant, or a site a friend made. The good news is that most changes only need a handful of concepts. Open the file in a plain text editor, keep a backup copy, and work through this guide.
How a page fits together
- HTML is the content and its structure: headings, paragraphs, images, links.
- CSS is the look: colors, fonts, spacing and layout.
- JavaScript adds behavior, such as menus that open. You can often leave it alone.
A minimal page looks like this:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My page</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<h1>Hello</h1>
<p>Welcome to my page.</p>
</body>
</html>
Everything inside <head> is information about the page. Everything inside <body> is what visitors see.
The tags you will meet most
| Tag | What it does | Example |
|---|---|---|
<h1> to <h3> |
Headings, from most to least important | <h2>Our menu</h2> |
<p> |
A paragraph | <p>Open daily.</p> |
<a href="..."> |
A link | <a href="about.html">About</a> |
<img src="..." alt="..."> |
An image, with a text description | <img src="images/cafe.jpg" alt="Our cafe"> |
<ul> and <li> |
A bulleted list | <li>Espresso</li> |
<div> and <section> |
Boxes that group content for layout | <section class="hero"> |
Common edits
Change text. Use your editor’s search to find the words, change them, and leave the tags around them untouched.
Swap an image. Put your image in the same folder as the old one and change the src to its file name. Update the alt text so it describes your image.
Change a link. Edit the href. Use a full address (https://...) for other websites and a relative path (contact.html) for your own pages.
Change a color. Colors live in CSS, either in a <style> block in the <head> or in a separate .css file. Search for color: or background. Many modern pages define colors once at the top, as variables:
:root {
--brand: #1f6feb;
}
Change the value there and it updates everywhere.
Linking CSS correctly
If your page suddenly has no styling, the stylesheet link is usually wrong. Check three things:
- The
<link rel="stylesheet" href="...">tag is inside<head>. - The path matches the real folder and file name, including capital letters.
- The CSS file was uploaded along with the HTML.
The HTML path checker lists every stylesheet, script and image a page references and flags paths that will break once hosted.
Fixing common layout problems
| Symptom | Likely cause | Try this |
|---|---|---|
| Page is tiny on phones | Missing viewport tag | Add the viewport <meta> from the example above |
| Images overflow the screen | Fixed widths | Add img { max-width: 100%; height: auto; } to your CSS |
| Text runs edge to edge on wide screens | No maximum width | Wrap content and add max-width: 40rem; margin: 0 auto; |
| Everything is squashed together | Missing spacing | Add padding or margin to the containers |
| A change does nothing | Another rule overrides it, or the browser cached the old file | Reload with Shift held down, or check for a more specific rule |
See changes as you work
Save the file and refresh the browser to see each change. For quick experiments, paste the code into the HTML previewer: it updates as you type and shows phone and tablet widths. Change one thing at a time, so when something breaks you know what caused it.
Getting it online
When the page looks right, follow hosting an HTML file to publish it. If you started from an AI assistant’s code, AI-made pages covers the extra checks worth doing.
Quick checklist
- Backup copy saved before editing
- Doctype, viewport tag and title present
- Images have
alttext - Stylesheet path matches the real file
- Checked at phone width before publishing
Tools
Free tools
Small, free tools that run right in your browser. No sign-up, nothing to install.
-
HTML previewer
Paste HTML and CSS, see it live in a safe sandbox, then download it as an index.html file.
Open tool -
File size checker
See if your files fit a host's upload limits before you try. Nothing is uploaded.
Open tool -
HTML path checker
List every link, image and script in a page and flag the paths that will break once hosted.
Open tool