<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<!-- Content goes here -->
</body>
</html>- HTML elements can have attributes.
- Example of an anchor (
<a>) with an attribute:<a href="page.html">Click here</a>
- Example of an image:
<img src="image.jpg" alt="Description">
- 🔹
href→ used in links - 🔹
src→ used in images (source) - 🔹
alt→ describes the image ⚠️ <img>is self-closing
- Ordered list →
<ol> - Unordered list →
<ul> - List item →
<li>
<ol>
<li>First</li>
<li>Second</li>
</ol>Used for:
- Bullet/numbered content
- Navigation
- Organizing content
- CSS is written in property-value pairs
- Always use
:between property and value, and end with;
color: red;
font-size: 21px;
font-weight: bold;<p style="color: steelblue; font-size: 21px;">Text</p>colorfont-sizefont-weightbackground-colortext-align
Colors can be defined using:
- Keywords:
red,steelblue,hotpink - Hex codes:
#ff0000 - RGB:
rgb(255, 0, 0) - HSL:
hsl(0, 100%, 50%)
p {
color: black;
}<p class="intro">Hello</p>.intro {
font-size: 18px;
}<p id="unique">Only me</p>#unique {
font-weight: bold;
}- 🔸 Use
.for class selectors - 🔸 Use
#for ID selectors - 🔹 IDs should be unique
- 🔹 Classes can be reused
Link it in the <head>:
<link rel="stylesheet" href="styles.css">- Keeps your HTML clean
- Viewer won’t see the CSS directly
-
HTML:
<!-- This is a comment --> -
CSS:
/* This is a comment */
<header>– Top intro section<nav>– Navigation links<main>– Main page content<section>– Thematic grouping<footer>– Bottom info<div>– Generic container
- Default width:
100% - Default height:
0, grows with content - Stack vertically
Space outside the element
margin: 10px 20px 30px 40px;
/* top right bottom left */Shortcuts:
margin: 10px; /* all sides */
margin: 10px 20px; /* top & bottom | left & right */
margin: 10px 20px 30px; /* top | left & right | bottom */Space inside the element (between content and border)
padding: 10px;border: 1px solid black;1px→ thicknesssolid→ style (solid, dashed, dotted...)black→ color
margin: 0 auto;
width: 50%;- Set
margin: autoto center - Must set a width for proper centering