Note: "table" is for tabular data, not for layout
A lot of deprecated ressources on the internet!
<p class="inner">
<img src="/img/logo.png" alt="Site logo" />
Go to my
<a href="http://example.com">
wonder full website
</a>
</p>
<p class="inner">
<img src="/img/logo.png" alt="Site logo" />
Go to my
<a href="http://example.com">
wonder full website
</a>
</p>
Opening tags
<p class="inner">
<img src="/img/logo.png" alt="Site logo" />
Go to my
<a href="http://example.com">
wonder full website
</a>
</p>
Closing tags
<p class="inner">
<img src="/img/logo.png" alt="Site logo" />
Go to my
<a href="http://example.com">
wonder full website
</a>
</p>
Self closing tags, <tag> or <tag />:
<p class="inner">
<img src="/img/logo.png" alt="Site logo" />
Go to my
<a href="http://example.com">
wonder full website
</a>
</p>
Attributes:
<p class="inner">
<img src="/img/logo.png" alt="Site logo" />
Go to my
<a href="http://example.com">
wonder full website
</a>
</p>
Mandatory attributes:
<p class="inner">
<img src="/img/logo.png" alt="Site logo" />
Go to my
<a href="http://example.com">
wonder full website
</a>
</p>
Urls, if the file is read from "http://toto.org/user/tata":
Note the absence/presence of opening and trailing "/"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="description" content="Hello!">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="description" content="Hello!">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Doctype: what version of html do we use
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="description" content="Hello!">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Header: not displayed, mainly "metadata".
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="description" content="Hello!">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Declare encoding (depends on your editor's settings):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="description" content="Hello!">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Description, to help search engines
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="description" content="Hello!">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Include CSS file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hi!</title>
<meta name="description" content="Hello!">
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
Body: all the content of the page
Escaping code | Rendered symbol |
---|---|
< | < |
> | > |
| (non-breaking space) |
– | – |
& | & |
É (useless with utf-8) | É |
&aagrave; (useless with utf-8) | à |
... | ... |
<J'aime la crème "crémeuse">
<J'aime la crème "crémeuse">
<J'aime la crème "crémeuse">
<J'aime la crème "crémeuse">
<J'aime la crème "crémeuse">
Escaping is important against
Arthur wrote: <p onload="send_passwords()">Hello</p>
Escaping is important against
p {
color: red;
background-color: #ff00ff;
}
p {
color: red;
background-color: #ff00ff;
}
All the <p> tags
p {
color: red;
background-color: #ff00ff;
}
All the <p> tags
are written in red with pink background
p a {
...
}
All the <a> tags inside a <p> tag
p a {
...
}
All the <a> tags inside a <p> tag
<p><a href="...">Blah</a></p>
<a href="...">Doh!</a>
.foo {
...
}
All the tags with a class "foo"
.foo {
...
}
All the tags with a class "foo"
<p class="foo">Blah</p>
<p>Hey, <span class="foo">Doh!</span></p>
#bar {
...
}
All the tags with THE id "bar"
<p id="qix">Blah</p>
<p>Hey, <span id="bar">Doh!</span></p>
#bar {
...
}
All the tags with THE id "bar"
<p id="qix">Blah</p>
<p>Hey, <span id="bar">Doh!</span></p>
Id has to be unique among an HTML document
#bar, .foo {
...
}
All the tags with THE id "bar", or a class foo
<p class="foo">Blah</p>
<p>Hey, <span id="bar">Doh!</span></p>
Mix!
.foo a.bar
#menu .major, #cie-desc .major
.btn:hover
Mix!
.foo a.bar
/* <a> tags with bar class, within a tag with foo class */
#menu .major, #cie-desc .major
/* tags with major class, within either menu or
cie-desc id */
.btn:hover
/* tags with btn class, when the mouse is over the
element */
Mix!
.foo a.bar
/* <a> tags with bar class, within a tag with foo class */
#menu .major, #cie-desc .major
/* tags with major class, within either menu or
cie-desc id */
.btn:hover
/* tags with btn class, when the mouse is over the
element */
Pseudo selector