+ All Categories
Home > Documents > HTML 5/CSS 3/Javascript -...

HTML 5/CSS 3/Javascript -...

Date post: 26-Oct-2019
Category:
Upload: others
View: 18 times
Download: 0 times
Share this document with a friend
27
Transcript

Université de BordeauxInternational Track - Informatics Unit.

Initiation au développement Web

HTML 5/CSS 3/Javascript

Florent Grélard, Marie Beurton-Aimar (Étienne André)[email protected]

http://dept-info.labri.fr/~beurton

Version : 15 avril 2019 (diapositives de présentation)

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 1 / 24

CSS

Dé�nition (CSS)

CSS (Cascading Style Sheets, is a language allowing description of HTMLpage presentation.

Standard developped by the W3C.

CSS is updated by level and not by version.

Level 3 reuses and extends the 1 and 2 levels.

Di�erent from HTML !

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 2 / 24

CSS

Dé�nition (CSS)

CSS (Cascading Style Sheets, is a language allowing description of HTMLpage presentation.

Standard developped by the W3C.

CSS is updated by level and not by version.

Level 3 reuses and extends the 1 and 2 levels.

Di�erent from HTML !

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 2 / 24

Principle : format and content are separated.

Principle

The principle is to separate the content (HTML) to the format (CSS).

A CSS style sheet build the format of the HTML page.

Good practice

An HTML site well designed has to not contain any style information insidethe HTML documents.

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 3 / 24

CSS3 Syntax - simple Example

Page HTML :

. . .<h1>Happy Together</h1><p>Wong Kar−Wai movier e a l i z e d i n 1997</p>. . .

Style sheet :

body {c o l o r : #000080;

}

h1 {font−we ight : bo ld ;font−s t y l e : i t a l i c ;c o l o r : r ed ;font−s i z e : 24px ;

}

Displaying :

Happy Together

Wong Kar-Wai Movie realized in 1997

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 4 / 24

CSS3 Syntax - simple Example

Page HTML :

. . .<h1>Happy Together</h1><p>Wong Kar−Wai movier e a l i z e d i n 1997</p>. . .

Style sheet :

body {c o l o r : #000080;

}

h1 {font−we ight : bo ld ;font−s t y l e : i t a l i c ;c o l o r : r ed ;font−s i z e : 24px ;

}

Displaying :

Happy Together

Wong Kar-Wai Movie realized in 1997

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 4 / 24

Main Syntax of the CSS sheet

Selecting︷︸︸︷h1 {

font-weight︸ ︷︷ ︸Property

: bold︸︷︷︸Values

;

font-family︸ ︷︷ ︸Property

: Times New Roman, Times, serif︸ ︷︷ ︸Values

;

}

Remarques :

Extending .css

No head part or bottom in a CSS �le.

Syntax no sensible to the space or end of line.I BUT indentation is strongly recommanded !

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 5 / 24

Style included or separeted ? (1/2)

Bad :

<h1 s t y l e=" c o l o r : r ed ">Happy Together</h1>

A little bit better :

<head>. . .<s t y l e type=" t e x t /CSS" >

h1 { c o l o r : r ed ; }</ s t y l e>

. . .</head><body>

<h1>Happy Together</h1></body>

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 6 / 24

Style included or separeted ? (2/2)

Godd :

<head>. . .< l i n k r e l=" s t y l e s h e e t " type=" t e x t / c s s "

media=" s c r e e n " h r e f="mys ty l e . c s s " />. . .</head>

<body><h1>Happy Together</h1>

</body>

. . .where mystyle.css is a separeted �le de�ning the properties of <h1>(and of the others tags).

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 7 / 24

Comments

Comments are CSS code which is not executed, so not taken into accountby the browser.Syntax : /* Text in comments */

body {c o l o r : #000080; /∗ the c o l o r ∗//∗ t ex t−d e c o r a t i o n : l i n e−th rough ; ∗/}

Attention

Comments stay visible in the source style sheet, which is visible from theclient part.

DO NOT leave inside con�dential information !

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 8 / 24

Comments

Comments are CSS code which is not executed, so not taken into accountby the browser.Syntax : /* Text in comments */

body {c o l o r : #000080; /∗ the c o l o r ∗//∗ t ex t−d e c o r a t i o n : l i n e−th rough ; ∗/}

Attention

Comments stay visible in the source style sheet, which is visible from theclient part.

DO NOT leave inside con�dential information !

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 8 / 24

Displaying text

Properties : styles

Property font-size : police sizeI Constant predefined values : xx-small, x-small, medium, large,

x-large, xx-largeI Relative predefined values : smaller, largerI Numeric values : x units, where unit ∈ {pt, px, em, %}

Property font-weight : thickness of the policeI Predefined values : lighter, normal, bold, bolderI Numeric values : x ∈ [0; 1000] (1000 is the most thick)

Property font-style : tilting of the policeI Predefined values : normal, italic, oblique

Property text-decoration : decoration (underline, overline)I Predefined values : underline, overline, line-through, none

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 9 / 24

Displaying text

Properties : police

Property font-family : families of font policesI Major families : serif, sans-serif, mono, monospaceI Police name : Arial, Courier New, Courier, Helvetica, Times New

Roman, Times, and more ...

vif zephyr vif zephyr vif zephyrserif sans-serif monospace

Good practices for typography

1 Titles are most often with sans-serif, and body with serif.

2 It is recommended to not mix font families into the same document.

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 10 / 24

Displaying text

Properties : colors

Property color : police colors

I Predefined colors : red, blue, green, orange, etc.F See examples at web-color.aliasdmc.fr/

I Users values :F Hexadecimal : #RRVVBBF RVB : rgb(r, g, b) with values from 0 to 255F RVB : rgb(r%, g%, b%) with values from 0 to 100F RVB + transparency : rgba(r, g, b, a) with values from 0 to 255,

and transparency (a) between 0 and 1F HSL (color / saturation / light) : hsl and hsla

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 11 / 24

Displaying text

Format - Identi�ants and classes

Identi�ants

Syntax HTML : <h1 id="title">

Syntax CSS : h1 #title { ... }

Usage unic (only one id=title in the HTML page.)

Classes

Syntax HTML : <h1 class="title">

Syntax CSS : h1 .title { ... }

Usage multiple (several class=title autorized in the HTML page.)

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 12 / 24

Displaying text

Identi�ants and classes : example

Page HTML :

<h2 i d=" prem i e r ">As Tears Go By</h2><h2>Nos annees sauvage s</h2><h2 c l a s s=" b l eu ">Les Cendres du temps</h2><h2>Chungking Exp r e s s</h2><h2 c l a s s=" b l eu ">Les Anges dechus</h2>

Style sheet :

h2 {font−s t y l e : i t a l i c ;

}#pr em i e r {

c o l o r : r ed ;}. b l e u {

c o l o r : b l u e ;}

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 13 / 24

Displaying text

Identi�ants and classes : example (displaying)

As Tears Go By

Nos annees sauvages

Les Cendres du temps

Chungking Express

Les Anges dechus

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 14 / 24

Displaying text

Inheritance

CSS properties inherit from parent properties.

Inheritance specialisation of property :

h2 #first inherits from h2

h2 .blue inherits from h2 (but not from h2 #first)

Inheritance by property semantically parented :

h2 inherits from body

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 15 / 24

Displaying text

Margins and edges

All HTML element is considered as contained in a box, de�ned with :

internal surface (background)

internal space (padding)

edge (border)

external margin (margin)

margin

border

padding

background

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 16 / 24

Displaying text

Margins and edges : example<p c l a s s=" bo i t e o r a ng e ">Smal l example coming from the

Wikibook about CSS ( Cascad ing S t y l e Shee t s ) .</p>

p . bo i t e o r a n g e {bo rde r : 1px do t t ed b l a ck ;padding−top : 1em ;padding−r i g h t : 2em ;padding−bottom :3em ;padding− l e f t : 4 em ;background−c o l o r :# f c9 ;width :10em ;t ex t−a l i g n : j u s t i f y

}

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 17 / 24

Displaying text

W3C - Veri�cation

As for HTML, W3C and Mozilla fondation provide a validator of CSS3code.

http://jigsaw.w3.org/css-validator/

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 18 / 24

Displaying text

An example without CSS

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 19 / 24

Displaying text

Same example with CSS

Code HTML identicalSimple adding of a style sheet.

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 20 / 24

Displaying text

Sources and references

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 21 / 24

Displaying text

Sources and references

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 22 / 24

Displaying text

Sources and references

References

Documents � Une Contre Histoire des Internets � (J. Goetz and J.M.Manach)http://lesinternets.arte.tv/

Speci�cation of HTML5 (recommandation of the 28/10/2014)http://www.w3.org/TR/html5/

Sources

Histoire de HTML : Wikipedia > HTMLhttp://fr.wikipedia.org/wiki/HTML

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 23 / 24

Displaying text

Sources and references

References

Le langage CSS (Wikilivres)https://fr.wikibooks.org/wiki/Le_langage_CSS

Cascading Style Sheets (Wikbooks), en anglais mais plus complethttps://en.wikibooks.org/wiki/Cascading_Style_Sheets

Sources

La speci�cation de CSS(3) par le W3Chttp://www.w3.org/TR/CSS/

Media Querieshttps://en.wikipedia.org/wiki/Media_queries

Florent Grélard/Marie Beurton-Aimar (Université de Bordeaux)Programmation évenementielle 2017�2018 24 / 24


Recommended