2022
Client
Server
<p>
</p>
My Text
element
opening tag
content
closing tag
element name
<!DOCTYPE html>
<html>
<head>
<title>Hello Internet</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
https://www.ju.se/somefolder/somefile.html
Scheme
URL (Uniform Resource Locator)
host
path
filename
garrit.png
images/garrit.png
./images/garrit.png
/images/garrit.png
../garrit.png
File is located in same folder as current page
File is located in images in current folder
Same as above
File is located in the image folder on the root
File is located in the folder one level up
In computer science, the term semantics refers to the meaning of language constructs, as opposed to their form (syntax).
<div>
<div>
<ul>
<li>Home</li>
<li>NMD</li>
</ul>
</div>
</div>
<div>
<div>
<div>A long text about NMD...</div>
<div>Some more text about Web and User Interface Design!</div>
</div>
<div>About me</div>
</div>
<div>
Made with ❤️ in Jönköping
</div>
<header>
<nav>
<ul>
<li>Home</li>
<li>NMD</li>
</ul>
</nav>
</header>
<main>
<section>
<article>A long text about NMD...</article>
<article>Some more text about Web and User Interface Design!</article>
</section>
<aside>About me</aside>
</main>
<footer>
Made with ❤️ in Jönköping
</footer>
What do you see?
What do you see now?
<footer>...</footer>
<p>...</p>
<h1>...</h1>
Elements can be selected via selectors and have attributes.
background-color
background-image
background
border-width
border-style
border-color
border
float
margin
padding
position
color
text-align
text-decoration
font-family
font-size
font-style
font-weight
Or just google: CSS reference
Red
Green
Blue
Red
Green
Blue
=
255
=
255
=
255
Red
Green
Blue
=
0
=
0
=
0
Red
Green
Blue
=
255
=
0
=
0
Red
Green
Blue
=
0
=
255
=
0
Red
Green
Blue
=
0
=
0
=
255
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
---|---|---|---|---|---|---|---|---|---|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 |
---|---|---|---|---|---|
A | B | C | D | E | F |
0%
100%
255
0
50%
127
...
...
...
...
.content {
background-color: rgba(255, 255, 255, 0.5);
}
Centimeters
Millimeters
Quarter-millimeters
Inches
Picas
Points
Pixels
Parent font size, or font size of the element
x-height of the element's font
Measure of the glyph 0 of the element's font
Font size of the root element
Line height of the element
1% of the viewport's width
1% of the viewport's height
1% of the viewport's smaller dimension
1% of the viewport's larger dimension
Percentage of your parents Element
<h1>My headline</h1>
h1 {
font-size: 10em;
}
<p>I ❤️ HTML and CSS</p>
p {
color: #ff00ff;
}
<div class="content">I ❤️ HTML and CSS</div>
.content {
font-size: 2em;
}
<div class="content blue">I ❤️ HTML and CSS</div>
.content {
font-size: 2em;
}
.blue {
background-color: #0000ff;
}
<input id="name" placeholder="Your name"></input>
#name {
font-size: 1.5em;
color: #00ff00;
}
<div class="content blue">I ❤️ <span>HTML</span> and <span>CSS</span></div>
.content > span {
font-size: 1.5em;
color: #00ff00;
}
All p elements where parent is div
Select multiple elements
All p elements that are next to ul elements
All elements
All p-elements with class
Is selected when the element gets focus
Is selected when the element is hovered
Selects all p-elements that are the first child of their parent
<!DOCTYPE html>
<html>
<head>
<title>Hello Internet</title>
<link rel="stylesheet" type="text/css" href="example.css" />
</head>
<body>
<h1>Hello World!</h1>
<p class="content blue">This is some content! And my name is <span id="name">Garrit</span>!</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Hello Internet</title>
<style>
.content {
font-size: 2em;
}
.blue {
background-color: #0000ff;
}
#name {
font-size: 3em;
color: #00ff00;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<p class="content blue">This is some content! And my name is <span id="name">Garrit</span>!</p>
</body>
</html>
VS Code has a nice little helper...
Most Webserver will automatically select the file that is named index.html as default page to deliver.