HTML Hello World: Your First Web Page
Write your first web page in HTML — a heading and a paragraph — and watch it appear in the live preview. Start learning HTML for free.
<p>This is a paragraph.</p>The essential HTML & CSS syntax on one page. Every snippet comes from a lesson of our interactive Learn HTML & CSS course — click "Practise" to write it yourself and get instant feedback.
Last updated on .
Write your first web page in HTML — a heading and a paragraph — and watch it appear in the live preview. Start learning HTML for free.
<p>This is a paragraph.</p>Learn HTML headings from h1 to h6, paragraphs and line breaks, and how strong and em mark important and emphasised text. Free interactive lesson.
<h1>Dragon Care Guide</h1>
<h2>Feeding</h2>
<h3>Breakfast</h3>
<h3>Dinner</h3>
<h2>Training</h2>Learn HTML links — the a tag and href, absolute vs relative URLs, opening a new tab safely with target and rel, and jumping to a section with
<a href="https://developer.mozilla.org">MDN Web Docs</a>Add images to a web page with the HTML img tag — src, width and alt text — and learn why good alt text matters for accessibility and SEO.
<img src="/icons/owl.svg" alt="A wise owl">Learn HTML lists — bulleted lists with ul, numbered lists with ol and list items with li — and how to nest one list inside another.
<ul>
<li>Sword</li>
<li>Shield</li>
<li>Potions</li>
</ul>Learn the semantic HTML elements header, nav, main, section, article and footer, and why a meaningful page structure helps accessibility and SEO.
<div class="header">
<div class="nav">...</div>
</div>
<div class="main">...</div>Build HTML tables for tabular data — rows with tr, header cells with th, data cells with td — grouped with thead and tbody, plus a caption.
<table>
<tr>
<td>Ada</td>
<td>Mage</td>
</tr>
<tr>
<td>Linus</td>
<td>Knight</td>
</tr>
</table>Build HTML forms with labelled text, email, number and checkbox inputs, select menus, textareas, buttons, placeholders and required fields.
<form action="/signup" method="post">
<label for="hero">Hero name</label>
<input type="text" id="hero" name="hero">
<button type="submit">Join</button>
</form>Learn what CSS is and how to write CSS rules with element, class, id and group selectors — plus how the cascade decides which style wins.
<head>
<meta charset="utf-8">
<title>My page</title>
<style>
h1 {
color: teal;
}
</style>
</head>Learn CSS colours — named, hex and rgb() — text and background colours, and the CSS units px, em, rem and % for font sizes and widths.
h1 { color: tomato; } /* a named colour */
h1 { color: #ff6347; } /* hex */
h1 { color: rgb(255, 99, 71); } /* rgb() */Style text with CSS — font-family stacks, font-size, font-weight, line-height, text-align and text-decoration — and make any page easy to read.
body {
font-family: Georgia, "Times New Roman", serif;
}
code {
font-family: Consolas, "Courier New", monospace;
}Understand the CSS box model — content, padding, border and margin — and how box-sizing border-box makes the width of a box easy to predict.
.card {
width: 300px;
padding: 20px;
border: 2px solid #333;
margin: 24px;
}Learn the CSS display property: block vs inline vs inline-block elements, hiding elements with display: none, and why every page layout starts here.
<p>This paragraph is a block. <strong>This is inline</strong> and <a href="#">so is this link</a>.</p>
<p>A second block always starts on a new line.</p>Learn CSS flexbox: display: flex, flex-direction, justify-content, align-items and gap. Build a row of buttons and a perfectly centred hero section.
<div class="toolbar">
<button>Save</button>
<button>Share</button>
<button>Delete</button>
</div>Make flexbox rows wrap and share space with flex-wrap, flex-grow, flex-shrink, flex-basis and the flex shorthand. Build a search bar and a card row.
.tags {
display: flex;
flex-wrap: wrap;
gap: 8px; /* used between items and between lines */
}Learn CSS Grid layout: display: grid, grid-template-columns with fr units and repeat(), gap, and spanning columns with grid-column. Build a dashboard.
.gallery {
display: grid;
grid-template-columns: 200px 200px 200px; /* three columns, 200px each */
}Make pages work on phones and desktops: the viewport meta tag, CSS media queries with max-width and min-width, rem units and centred containers.
<meta name="viewport" content="width=device-width, initial-scale=1">Style elements by state and position with CSS pseudo-classes: :hover, :focus, :first-child, :last-child and :nth-child. Build a menu and a striped table.
.btn {
background: #f5b301;
}
.btn:hover {
background: #ffc935; /* a little lighter while hovered */
}Learn CSS positioning: relative, absolute, fixed and sticky, with top, right and z-index. Pin a badge to a card's corner and build a sticky header.
.nudge {
position: relative;
top: 4px; /* 4px lower than normal */
left: 8px; /* 8px further right */
}Learn CSS custom properties (--name and var()) and smooth hover effects with transition and transform. Build themeable shop cards that lift on hover.
:root {
--accent: #f5b301;
--radius: 12px;
}
.button {
background: var(--accent);
border-radius: var(--radius);
}