HTML & CSS basics
HTML & CSS basics
</html>
<!-- end of file -->
HTML SKELETON
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
<!-- end of file -->
HTML SKELETON - HEAD
<!DOCTYPE html>
<html>
<head>
<title>Page Title. Maximum length 60-70 characters</title>
<meta name="description" content="Page description. No longer t
<meta charset="utf-8">
</head>
<body>
</body>
</html>
<!-- end of file -->
HTML SKELETON - HEAD & GOOGLE
<head>
<!-- Google result text-->
<title>Coding Bootcamp Le Wagon | Europe's Best Coding Bootcamp</
<!-- Google result description-->
<meta name="description" content="Le Wagon is Europe’s best codin
</head>
HTML SKELETON - HEAD & FACEBOOK
<head>
<meta property="og:title" content="Le Wagon - The French innovati
<meta property="og:image" content="facebook-card.jpg">
<meta property="og:description" content="Le Wagon is the best Fre
<meta property="og:site_name" content="Le Wagon"/>
</head>
HTML SKELETON - HEAD & TWITTER
<head>
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@Lewagonparis">
<meta name="twitter:title" content="Le Wagon - The French innovat
<meta name="twitter:description" content="Le Wagon is the best Fr
<meta name="twitter:creator" content="@Lewagonparis">
<meta name="twitter:image:src" content="http://twitter-card.jpg">
</head>
HTML SKELETON - BODY
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello world</title>
</head>
<body>
<h1>Hello buddies!</h1>
</body>
</html>
<!-- end of file -->
BASIC SYNTAX
EXAMPLE
<a href="https://www.lewagon.com" target="_blank">
Le Wagon
</a>
Result: Le Wagon
QUIZZ
What is the name of the tag?
What is the content?
What are the 2 attributes (name and value)?
TITLES
<h1>[...]</h1>
<h2>[...]</h2>
<h3>[...]</h3>
<h4>[...]</h4>
<h5>[...]</h5>
<h6>[...]</h6>
PARAGRAPHS
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Veritatis laboriosam mollitia autem at ab omnis iure quis
asperiores inventore eos nam aut iusto officiis deserunt
nihil, sequi tempore impedit quae?
</p>
EMPHASIZE
<p>
You can emphasize <em>some words</em>,
and even <strong>more if needed</strong>
</p>
LISTS
<h2>Shopping List</h2>
<ul>
<li>Milk</li>
<li>Butter</li>
</ul>
x
COLORS - TIPS
body {
color: rgb(10, 10, 10);
}
You can now use any of the free Font Awesome icons 🎉
SMALL TIPS
Use the inspector, then copy the css in your text editor.
LIVE-CODE
Let's design our fonts and colors using Google fonts.
DIV AND BOX MODEL
REAL LIFE...
... IS MADE OF <DIV>
BOX MODEL
BOX MODEL - BORDER
BORDERS
div {
border: 1px solid red;
}
/* or */
div {
border-top: 1px solid red;
border-right: 2px dotted black;
border-bottom: 1px dashed green;
border-left: 2px dotted black;
}
BORDER RADIUS
BORDER RADIUS
BOX SHADOW
UNITS
/* Absolute */
p {
width: 50px;
}
/* Relative to parent */
p {
width: 50%;
}
RESULT:
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos voluptatibus, quis iure vel
aliquam veritatis architecto fugiat necessitatibus? Quidem error explicabo nemo maiores
voluptatem odio delectus ad, esse reprehenderit animi.
DIV CENTERING TECHNIQUE
width: 300px; /* Set the width */
margin: 0 auto; /* Set automatic margins on right/left */
RESULT:
.btn-red or .btn-signup?
.background-blue or .background-home?
.img-user or .img-circle?
combined with
/* style.css */
h1 {
color: red;
font-weight: bold;
}
combined with
/* style.css */
.text-justify {
text-align: justify;
}
combined with
/* style.css */
#banner {
background-image: url("example.jpg");
background-size: cover;
}
will put an image background on the unique div with
DESCENDANT SELECTORS
<!-- index.html -->
<body>
<div id="banner">
<h1>Le Wagon</h1>
<p>We bring tech skills to creative people</p>
</div>
</body>
combined with
/* style.css */
#banner h1 {
color: white;
}
combined with
/* style.css */
#navigation > li > a {
color: blue;
}
a direct children of li direct children of id="navigation"
GROUPING
/* style.css */
h1, h2, h3 {
font-weight: bold;
}
a:hover {
text-decoration: underline;
}
will make links underlined when the mouse hovers over them.
combined with
/* style.css */
p {
color: black;
}
.text-red {
color: red;
}
QUIZZ #2
<!-- index.html -->
<body>
<p id="bio" class="text-red">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</p>
</body>
combined with
/* style.css */
.text-red {
color: red;
}
#bio {
color: green;
}
SPECIFICITY OF SELECTORS
p { /* least specific */
color: black;
}
.text-red { /* ↓ */
color: red;
}
#bio { /* most specific */
color: green;
}