HTML P10 CSS
HTML P10 CSS
• CSS adalah standar pembuatan dan pemakaian style (font, warna, jarak baris, dll) untuk
dokumen terstruktur
• CSS memisahkan presentation sebuah dokumen dari content dokumen itu sendiri
Sintaks Rule
– Selector
• Contoh rule :
h1 { color: blue }
Keterangan:
– Selector : h1
– Property : color
– Value : blue
SUWINARNO NADJAMUDDIN 1
• Embedded Style Sheet (di dalam dokumen HTML)
o <style type="text/css">
h1 {color: blue}
</style>
o <style type="text/css">
@import url(http://webku.com/cool.css);
</style>
• Isi file eksternal sama dengan kode di antara tag <style> </style>
• Grouping (pengelompokan) :
• Inheritance (pewarisan) :
Bila style tidak didefinisikan, maka akan digunakan definisi style dari induknya
SUWINARNO NADJAMUDDIN 2
Macam-macam Selector
h1 {color: green}
i {font-style: normal}
• Class
• ID
• Kontekstual
h1 i {color: navy}
SUWINARNO NADJAMUDDIN 3
div.mhs .alamat b {color: green}
Specificity
• Contoh :
Pseudo Class
SUWINARNO NADJAMUDDIN 4
• Pseudo class dapat digunakan sebagai selector meskipun class-nya tidak
terdapat di kode HTML
– :link
– :visited
– :hover
– :active
– :focus
• Contoh :
Pseudo Element
– :first-letter
– :first-line
• Contoh :
SUWINARNO NADJAMUDDIN 6