Web DevelopmentLesson 3 of 21 · tap to see all lessons
Web Development · Beginner
Build Your First Web Page with HTML and CSS
Write a real web page from scratch: HTML for structure, CSS for style. Edit the code here and watch the preview update as you type.
- Qyubie Learn Editorial Team
- Published
- 7 min read
Includes 1 exercise and 1 quick check you can do right here.
Every web page you've ever visited is built from two languages working together: HTML describes what is on the page (a heading, a paragraph, a list), and CSS describes how it looks (colors, sizes, spacing). In this guide you'll build a small profile page with both.
By the end of this guide you will be able to:
- explain what HTML elements and tags are,
- write headings, paragraphs, lists, links, and images,
- add CSS rules that change color, size, and spacing, and
- read the basic structure of any web page.
What you need: nothing installed. Every editor on this page shows a live preview under the code — change the code and the preview updates.
HTML: elements and tags
HTML marks up content with tags in angle brackets. Most elements have an opening tag, content, and a closing tag with a slash:
<p>This is a paragraph.</p><p>is the opening tag,</p>the closing tag.- Together with the text between them, they form a paragraph element.
Headings go from <h1> (most important, biggest) to <h6>. A page normally has one <h1>.
Try it · HTML & CSS
Try it: change the name, add another paragraph, or turn the <h2> into an <h3> and watch the size change.
Lists, links, and images
Use <ul> for a bulleted (unordered) list and <ol> for a numbered (ordered) list. Each item is an <li>.
A link is an <a> element; its attribute href holds the address. Attributes go inside the opening tag as name="value".
Try it · HTML & CSS
Images use <img>, which has no closing tag. The src attribute is the picture's address, and alt describes it for people who can't see it — screen-reader users, or anyone whose image didn't load. Always write a useful alt.
<img src="campus.jpg" alt="Students walking across the campus quadrangle">Quick check
The structure of a full page
A complete HTML document has a standard skeleton:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>My Profile</title>
</head>
<body>
<h1>Maria Santos</h1>
<p>Welcome to my page.</p>
</body>
</html><!DOCTYPE html>tells the browser this is modern HTML.<head>holds information about the page — its title (shown on the browser tab), character set, and styles.<body>holds everything you actually see.
CSS: rules that style elements
A CSS rule has a selector (which elements) and declarations (what to change) inside curly braces. Each declaration is property: value;.
<style>
h1 {
color: navy;
font-size: 40px;
}
</style>This says: every <h1> should be navy and 40 pixels tall. For now we put CSS inside a <style> element in the page. Try changing the colors and sizes below:
Try it · HTML & CSS
Colors can be names (navy, tomato) or hex codes like #211470 (red, green, and blue as two hex digits each).
Classes: styling some elements, not all
To style only certain elements, give them a class attribute and select it with a dot in CSS:
Try it · HTML & CSS
<div> is a generic box for grouping, and <span> is a generic piece of text. They do nothing on their own — they exist so you can style them.
The box model in one minute
Every element is a rectangular box with three layers around its content:
- padding — space inside the border,
- border — the line around the box,
- margin — space outside the border, between this box and others.
In the example above, change padding: 16px to padding: 40px, then try margin-bottom: 40px, and see which space changes.
Exercise · HTML & CSS
Your profile card
Build a small profile: an <h1> with a name, a paragraph about the person, and a <ul> list with at least two hobbies. Then add a CSS rule that changes the color of the h1.
Hint
Your CSS rule can look like h1 { color: teal; } — keep the space between h1 and { so the checker finds it. The list needs <ul> with <li> items inside.
Show a solution
Try it yourself first — you learn more from a wrong attempt than from reading an answer.
<style>
h1 { color: teal; }
</style>
<h1>Juan Dela Cruz</h1>
<p>Second-year student who enjoys coding and basketball.</p>
<ul>
<li>Basketball</li>
<li>Drawing</li>
</ul>
Common mistakes
- Forgetting a closing tag. A missing
</p>or</div>can make the rest of the page look wrong. Indent nested elements so you can see what closes what. - Missing semicolons in CSS.
color: red font-size: 20px;breaks both declarations. End each one with;. - Using headings for size. Pick headings for meaning (title, section, subsection) and use CSS to change size.
- Images without alt text. Always describe the image.
Summary
- HTML gives a page its structure with elements written as tags.
- Attributes like
href,src,alt, andclassadd information to elements. - CSS rules select elements and set properties like
color,font-size,padding, andmargin. - Classes let you style specific elements.
Next steps: open the playground, choose HTML & CSS, and rebuild this profile page about yourself — then add a second section with a different background color.