1 | < html > |
2 | < head > |
3 | < title >Ciao Web!</ title > |
4 | </ head > |
5 | < body > |
6 | < p >Il mio primo paragrafo HTML!</ p > |
7 | </ body > |
8 | </ html > |
1 | < nometag > |
1 | < p > |
2 | linea1< br > |
3 | linea2 |
4 | </ p > |
1 | < p > |
2 | Some random text... < img src = "imageurl.png" > |
3 | Some other text |
4 | </ p > |
Riproducete il seguente documento HTML utilizzando un editor di testi:
1 | < html > |
2 | < head > |
3 | < title >Ciao Web!</ title > |
4 | </ head > |
5 | < body > |
6 | < h1 >Titolo</ h1 > |
7 | < p >Il mio primo paragrafo HTML!</ p > |
8 | </ body > |
9 | </ html > |
Fogli di Stile a Cascata
mentre mediante HTML è possibile definire i contenuti e la struttura di un documento
In passato HTML prevedeva degli appositi tag e attributi di styling ma
poichè per modificare l’aspetto era necessario editare il documento e
spesso l’applicazione di stili arrivava a cambiare la struttura stessa del documento
I tag di stile sono di conseguenza stati
regola di selezione dei nodi di un documento HTML di cui si vuole modificare lo stile
proprietà (dei nodi HTML selezionati) di cui si vuole cambiare il valore
01 | .warning { |
02 | background-color : red ; |
03 | color : black ; |
04 | } |
05 |
06 | #sidebar, #footer { |
07 | font-size : 8pt ; |
08 | margin-right : 20px ; |
09 | } |
10 |
11 |
12 | #sidebar a:hover { |
13 | background-color : yellow; |
14 | } |
1 | < div id = "sidebar" > |
2 | < a href = "http://learn.alcacoop.it" >Link text</ a > |
3 | < span class = "warning" >warning message</ span > |
4 | </ div > |
5 |
6 | < div id = "footer" class = "warning" >random text</ div > |
1 | #sidebar {...} |
l’id associato ad un nodo deve essere unico all’interno del documento… ma il browser non effettua nessun controllo sull’unicità di tale identificativo
la presenza di più nodi con il medesimo id può generare problemi di rendering o interazione
1 | .warning {...} |
consente di selezione un gruppo di nodi attraverso una delle classi associate
1 | #sidebar, #footer {...} |
consente di associare lo stesso corpo di configurazione CSS ad un insieme di selettori
1 | #sidebar a {...} |
consente di selezionare dei nodi sulla base della loro posizione all’interno della struttura ad albero di un documento HTML
1 | a:hover {...} |
ricoprono selezioni non rappresentabili altrimenti come la selezione dei link visitati (pseudo classes) o la selezione di elementi non rappresentati da elementi HTML veri e propri (pseudo elements), come ‘first-letter’ o ‘first-line’
01 | < html > |
02 | < head > |
03 | < title >example</ title > |
04 | < style > |
05 | .warning { |
06 | background-color: red; |
07 | color: black; |
08 | } |
09 |
10 | #sidebar, #footer { |
11 | font-size: 8pt; |
12 | margin-right: 20px; |
13 | } |
14 |
15 | #sidebar a:hover { |
16 | background-color: yellow; |
17 | } |
18 | </ style > |
19 | </ head > |
20 | < body > |
21 | < div id = "sidebar" > |
22 | < a href = "http://learn.alcacoop.it" >Link text</ a > |
23 | < span class = "warning" >warning message</ span > |
24 | </ div > |
25 | < div id = "footer" class = "warning" >random text</ div > |
26 | </ body > |
27 | </ html > |
01 | < html > |
02 | < head > |
03 | < title >example</ title > |
04 | < link rel = "stylesheet" type = "text/css" href = "test.css" > |
05 | </ head > |
06 | < body > |
07 | < div id = "sidebar" > |
08 | < a href = "http://learn.alcacoop.it" >Link text</ a > |
09 | < span class = "warning" >warning message</ span > |
10 | </ div > |
11 | < div id = "footer" class = "warning" >random text</ div > |
12 | </ body > |
13 | </ html > |
Anche se CSS non è in realtà un linguaggio di programmazione, sono nati recentemente dei Framework che semplificano la creazione di design web che utilizzino le moderne tecniche di layouting e styling mediante CSS definendo una serie di classi CSS pronte per l’uso.
http://en.wikipedia.org/wiki/CSS_framework
Tra le nuove caratteristiche di CSS3 che i browser iniziano a supportare abbiamo:
1 | < root > |
2 | < child > |
3 | < subchild >.....</ subchild > |
4 | </ child > |
5 | </ root > |
1 | <? xml version = "1.0" encoding = "ISO-8859-1" ?> |
2 | < note > |
3 | < to >Tove</ to > |
4 | < from >Jani</ from > |
5 | < heading >Reminder</ heading > |
6 | < body >Don't forget me this weekend!</ body > |
7 | < attachment type = "gif" >computer.gif</ attachment > |
8 | </ note > |
come possiamo riconoscere il particolare dialetto utilizzato da un documento XML?
come possiamo far convivere diversi dialetti all’interno dello stesso documento?
vengono utilizzati per evitare conflitti sui tag XML
01 | < root xmlns = "http://alcacoop.it/randomdata/" > |
02 | < h:table xmlns:h = "http://www.w3.org/TR/html4/" > |
03 | < h:tr > |
04 | < h:td >Apples</ h:td > |
05 | < h:td >Bananas</ h:td > |
06 | </ h:tr > |
07 | </ h:table > |
08 | < f:table xmlns:f = "http://www.w3schools.com/furniture" > |
09 | < f:name >African Coffee Table</ f:name > |
10 | < f:width >80</ f:width > |
11 | < f:length >120</ f:length > |
12 | </ f:table > |
13 | </ root > |
Possibilità di mescolare più dialetti XML all’interno dello stesso documento XHTML:
Maggiore verbosità
Maggiore sensibilità rispetto agli errori
Un documento XHMTL deve essere un
01 | <? xml version = "1.0" encoding = "UTF-8" ?> |
02 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> |
03 | < html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en" > |
04 | < head > |
05 | < title >Title goes here</ title > |
06 | </ head > |
07 |
08 | < body > |
09 | Body content! |
10 | </ body > |
11 | </ html > |
01 | <? xml version = "1.0" standalone = "no" ?> |
02 |
03 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" |
05 |
06 | < svg width = "100%" height = "100%" version = "1.1" xmlns = "http://www.w3.org/2000/svg" > |
07 |
08 | < circle cx = "100" cy = "50" r = "40" stroke = "black" stroke-width = "2" fill = "red" /> |
09 |
10 | </ svg > |
01 | <? xml version = "1.0" encoding = "UTF-8" ?> |
02 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> |
03 | < html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en" > |
04 | < head > |
05 | < title >Title goes here</ title > |
06 | </ head > |
07 |
08 | < body > |
09 | < h1 >XHTML + SVG: un esempio</ h1 > |
10 |
11 | < svg width = "100%" height = "100%" version = "1.1" xmlns = "http://www.w3.org/2000/svg" > |
12 | < circle cx = "100" cy = "50" r = "40" stroke = "black" stroke-width = "2" fill = "red" /> |
13 | </ svg > |
14 | </ body > |
15 | </ html > |
1 | <? xml version = "1.0" encoding = "ISO-8859-1" ?> |
2 |
3 | < mail > |
4 | < to >Jack</ to > |
5 | < from >Davide</ from > |
6 | < subject >NOT PENNY'S BOAT</ subject > |
7 | < message >Corpo del messaggio di posta inviato</ message > |
8 | </ mail > |
01 | <? xml version = "1.0" encoding = "ISO-8859-1" ?> |
02 | < mymusic > |
03 | < track > |
04 | < title >Revolution</ title > |
05 | < artist >Bob Marley & The Wailers</ artist > |
06 | < album >Natty Dread</ album > |
07 | < genre >Reggae</ genre > |
08 | < length >4.24</ length > |
09 | < year >1978</ year > |
10 | </ track > |
11 | < track > |
12 | < title >Silver and Gold</ title > |
13 | < artist >Joe Strummer</ artist > |
14 | < album >Streetcore</ album > |
15 | < genre >Rock</ genre > |
16 | < length >4.56</ length > |
17 | < year >2003</ year > |
18 | </ track > |
19 | </ mymusic > |