Nicolas Feer
WIFI: Le Wagon Copenhagen
Password: rubyonrails
An introduction to HTML, CSS & JavaScript
Nicolas Feer
Ask for help when needed & have fun!
because you can :
to build a website :
content
+ structure
design
behavior
HTML is a markup language.
It structures the content of a web page.
Cause in order to design and animate its elements,
we have to organize them first
The Internet is REAL and it's made by us.
<!DOCTYPE html>
<!-- end of file --><!DOCTYPE html>
<html>
<!-- your content (text, images,...)
and all the other html tags
to structure this content goes here -->
</html>
<!-- end of file --><!DOCTYPE html>
<html>
<head>
<!-- intelligence (meta-data) -->
</head>
<body>
<!-- stuff to be displayed on your web page -->
</body>
</html>
<!-- end of file --><!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
<!-- text appearing in the tab + used by Google in its search results -->
<meta charset="utf-8"/>
<!-- to display properly the special characters -->
</head>
<body>
<!-- stuff to display in the page -->
</body>
</html>
<!-- end of file --><!DOCTYPE html>
<html>
<head>
<title>Hello world</title>
<!-- Text appearing in the tab + used by Google in its search results -->
<meta charset="utf-8"/>
<!-- To display properly the special characters -->
</head>
<body>
<h1>Hello buddies!</h1>
<!-- Stuff to display in the page -->
</body>
</html>
<!-- end of file --><element_name>element_content</element_name>
opening tag
closing tag
---------------
---------------
<element_name attribute_name="attribute_value">element_content</element_name>
opening tag
closing tag
-------------------------------------------
---------------
result => Le Wagon
QUIZ:
<h1>[...]</h1> <!-- Only one per page! SEO important -->
<h2>[...]</h2>
<h3>[...]</h3>
<h4>[...]</h4>
<h5>[...]</h5>
<h6>[...]</h6>titles
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
But the painful truth resilience at all by any law
inventor worse for them or just leave offices
there is nothing, which is an impediment to the time to follow?
</p>paragraphs
<h2>Shopping List</h2>
<ul>
<li>Milk</li>
<li>Butter</li>
</ul>
<h2>World Cup 2014</h2>
<ol>
<li>Germany</li>
<li>Argentina</li>
<li>Netherlands</li>
<li>Brazil</li>
</ol>lists
<img src="logo.png" alt="Le Wagon logo"/>images
graphical icons
You can get these icons both in :
<a href="http://www.lewagon.org" target="_blank">Le Wagon</a>links
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
<!-- end of file -->Setup your web page's overall html structure
<head>
<title>Hello world</title>
<!-- text appearing in the tab + used by Google in its search results -->
<meta charset="utf-8"/>
<!-- to display properly the special characters -->
</head>Setup your web page's head
<body>
<h1>My playground app</h1>
<p>A toy app to play with HTML and CSS</p>
<h2>Fast</h2>
<p>A fast app, <strong>very fast</strong> app</p>
<img src="#" alt="quick">
<h2>Simple</h2>
<p>A simple app, <strong>very simple</strong> app</p>
<img src="#" alt="simple">
<p>This page was coded by me!</p>
</body>Setup your web page's body
<img src="rocket.png">resources
CSS is used to add some style properties
to specific HTML elements
What would this website workuper.com look like without any CSS ?
For your CSS stylesheet to be taken into account, you need to
add a link to it in the head of the HTML document
/* syntax 1 : color name in English */
body {
color: orange;
}color
/* syntax 2 : hexadecimal color reference */
body {
color: # FFA500;
}color
/* syntax 3-a : RGB color reference */
body {
color: rgb(255, 165, 0);
}color
/* syntax 3-b : RGBA color & opacity reference */
body {
color: rgba(255, 165, 0, 0.8);
}color
RGBA has a 4th parameter: opacity
(which may vary between 0 and 1)
color tools
text color vs
background color
background image
fonts - family (1)
fonts - family (2)
fonts - family (3)
fonts - size & spacing
fonts - color
fonts - decoration
fonts - alignment
Google Fonts is a collection of beautiful web fonts that Google makes available for anyone for free
<link href="style.css" rel="stylesheet">body{
margin: 0px;
color: green;
background: rgb(245,245,245);
}
h1 {
font-family: courier;
color: rgb(212,57,43);
}
p {
font-size: 30px;
line-height: 20px;
}<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">textual icons
<h1><i class="fa fa-cutlery"></i> MY RESTAURANT</h1><link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<ul>
<li>
<a href="#"> <i class="fa fa-facebook"></i> </a>
</li>
<li>
<a href="#"> <i class="fa fa-twitter"></i> </a>
</li>
<li>
<a href="#"> <i class="fa fa-youtube"></i> </a>
</li>
<li>
<a href="#"><i class="fa fa-pinterest"></i></a>
</li>
</ul>
<p>This page was coded by me!</p>picture size & shape
img {
width: 100px;
}divisions and box model
Any modern website...
... is made of <div>
divisions and box model
=> structure your HTML code with <div> elements,
to group all the contents that fits together
divisions and box model
<div>
<h1>My Playground App</h1>
<p>A toy to play with HTML and CSS</p>
</div>
<div>
<h2>Fast</h2>
<img src="fast.png" alt="A rocket">
<p>A fast app, <strong>very fast app</strong> </p>
</div>
<div>
<h2>Simple</h2>
<img src="simple.png" alt="A cloud">
<p>A simple app, <strong>very simple</strong> app</p>
</div>Add a div around your footer too!
id and class
in your HTML file
the box model
syntax and shorcuts
div{
border-top: 1px solid red;
border-right: 2px dotted black;
border-bottom: 1px dashed green;
border-left: 2px dotted black;
}borders
divisions and box model
div{
background: white;
border: 1px solid lightgrey;
padding: 20px;
margin: 30px;
}you can make the box structure more visible
by adding some CSS rules on this <div>
id and class
To add some style only to :
#header {
text-align: center;
background-image: url("http://lorempixel.com/1300/1000");
background-size: cover;
padding: 150 0 500 0;
color: white;
text-shadow: 1px 1px 3px black;
}
.feature {
padding: 50px;
font-weight: 300px;
}#footer {
background-color: #555555;
padding: 10px 0px 100px 0px;
}
#footer p{
color: white;
}
#footer a {
color: lightgrey;
font-size: 30px;
}
#footer a:hover {
color: white;
}How does it work?
Always start with a container
then insert rows
then insert rows
more rows
The elementary block
<div class=“container”>
<div class=“row”>
<div class=“col-xs-6”></div>
<div class=“col-xs-6”></div>
</div>
</div>Mobile first means that .col-xs-6 will apply to larger screens
<div class=“container”>
<div class=“row”>
<div class=“col-xs-6”></div>
<div class=“col-xs-6”></div>
<div class=“col-xs-6”></div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-6 col-sm-3"></div>
<div class="col-xs-6 col-sm-3"></div>
<div class="col-xs-6 col-sm-3"></div>
<div class="col-xs-6 col-sm-3"></div>
</div>
</div>Can we offset a block?
Can we offset a block?
<div class="container">
<div class="row">
<div class="col-sm-offset-4 col-sm-4">
<!-- Le contenu de la div centrée -->
</div>
</div>
</div>Don't break succession
.container > .row > .col¡¡¡Don't change CSS code of .container, .row or .col elements!!!
<div class="wrapper-grey">
<div class="container">
<div class="row">
<div class="col-xs-6">
</div>
<div class="col-xs-6">
</div>
</div>
</div>
</div>Place a wrapper around the container
<div class="container">
<div class="row">
<div class="col-xs-6">
<div class="card">
...
</div>
</div>
<div class="col-xs-6">
<div class="card">
...
</div>
</div>
</div>
</div>Put cards inside the .col
.wrapper-grey {
background: #CCCCCC;
padding: 30px 0;
}
.card {
border: 1px solid grey;
padding: 30px;
background: white;
}As you're not touching grid elements,
the grid keeps its integrity
Start with a raw initial grid
Insert each feature in a col
<div class="col-xs-6 col-sm-3">
<div class="feature">
...
</div>
</div>
<div class="container">
<div class="row">
<div class="col-xs-6 col-sm-3"></div>
<div class="col-xs-6 col-sm-3"></div>
<div class="col-xs-6 col-sm-3"></div>
<div class="col-xs-6 col-sm-3"></div>
</div>
</div>JavaScript is a powerful dynamic language.
It can be used to animate or change your HTML content
All without reloading your page!
jQuery is a powerful and popular JavaScript library
Installed on 65% of top 10 million web pages
It's designed to make your life easy
Selects all divs on your page
$( "div" )Selects all tags with a "hello" class on your page
$( ".hello" )Finds the element with the "wagon" id on your page
$( "#wagon" )Any CSS Selector will do
$( "#footer>a>li" )Makes your #footer disappear
$( '#footer' ).hide()Makes your #footer reappear
Makes your #header appear gradually
$( '#header' ).fadeIn()Selects all divs on your page
$( '#footer' ).show()$( '#header' ).fadeOut()<script src="application.js"></script>$(document).ready(function() {
// Your code here
});Add a div with "main-title" id on
your h1, tagline and button
<div id="main-title">
<h1>The Best Page Ever</h1>
<p> Play with HTML and CSS!</p>
<button class="btn btn-danger">Sign Up</button>
</div>$(document).ready(function() {
$("#main-title").fadeIn(1000);
});#main-title {
display: none;
}