Css
Css
dokumen yang ditulis dalam bahasa markup. Penggunaan yang paling umum dari CSS adalah untuk memformat halaman web yang ditulis dengan HTML dan XHTML. Walaupun demikian, bahasanya sendiri dapat dipergunakan untuk semua jenis dokumen XML termasuk SVG dan XUL. Spesifikasi CSS diatur oleh World Wide Web Consortium (W3C). CSS digunakan oleh penulis maupun pembaca halaman web untuk menentukan warna, jenis huruf, tata letak, dan berbagai aspek tampilan dokumen. CSS digunakan terutama untuk memisahkan antara isi dokumen (yang ditulis dengan HTML atau bahasa markup lainnya) dengan presentasi dokumen (yang ditulis dengan CSS). Pemisahan ini dapat meningkatkan aksesibilitas isi, memberikan lebih banyak keleluasaan dan kontrol terhadap tampilan, dan mengurangi kompleksitas serta pengulangan pada stuktur isi. Cara pemanggilan CSS : 1. Internal Style Sheet atau Embed Style yaitu berada didalam tag <HEAD> dimana untuk
contoh ilustrasinya :
File3.html
contoh pertama : <html> <head> <title>Contoh Pertama</title> <style type="text/css"> body {background-color: yellow} h1 {background-color: red} h2 {background-color: transparent} p {background-color: rgb(250,0,255)} </style> </head> <body> <h1>This is header 1</h1> <h2>This is header 2</h2> <h1>This is header 3</h1> <p>This is a paragraph</p> </body> </html>
Contoh kedua : <HTML> <HEAD> <TITLE>Percobaan CSS : Inline Style </TITLE> </HEAD> <BODY style="color: blue"> <P style="text-align: center;text-transform: uppercase; color: red;font-weight: bold">Pemrograman</P> Web </BODY> </HTML>
Background
<html> <head> <style type="text/css"> body { background-image:url(PATH/img.jpg'); background-repeat: repeat; } </style> </head> <body> </body> </html>
Background-repeat: repeat-x; repeat-y; no-repeat Background - fixed <html> <head> <style type="text/css"> body { background-image: url(PATH/img.jpg'); background-repeat: no-repeat; background-attachment: fixed } </style> </head> <body> <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image <p>The image </body> </html>
will will will will will will will will will will will will will will will will will will will
not not not not not not not not not not not not not not not not not not not
scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll scroll
with with with with with with with with with with with with with with with with with with with
the the the the the the the the the the the the the the the the the the the
rest rest rest rest rest rest rest rest rest rest rest rest rest rest rest rest rest rest rest
of of of of of of of of of of of of of of of of of of of
the the the the the the the the the the the the the the the the the the the
page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p> page</p>
Penerapan dalam tag Heading adalah dengan menggunakan atribut class, seperti berikut:
<H1 class="merah">Batman</H1> <H1 class="biru">Jogja</H1>
Sedangkan untuk public class pendefinisian style dapat dipakai pada semua tag. Contohnya adalah sebuah definisi style berikut akan diterapkan pada tag Heading dan Paragraph: .warnatengah { color: red:
text-align: center; }
Pemakaian public class tersebut oleh tag Heading dan Paragraph, yaitu dengan menggunakan attribut class, seperti berikut:
<H1 class="warnatengah">Pemrograman</H1> <P class="warnatengah">Ternyata pemrograman asyik</P>
Id dalam CSS
Id memiliki sifat yang hampir sama dengan class yaitu style diterapkan pada tag, perbedaanya adalah tag dengan id tertentu bisa memperoleh tambahan style. Sehingga jika anda telah membuat class-class yang diterapkan pada tag sejenis, tetapi diinginkan salah satu tagnya memperoleh style yang sedikit berbeda maka dapat digunakan atribut id. Pendefinisian style untuk id harus mengandung tanda #. Contoh adalah didefinisikan style sebagai berikut:
H1.merah {color: red;} H1#beda {font-style: italic;}
Penerapan id dalam tag Heading adalah dengan menggunakan atribut class, seperti berikut:
<H1 class="merah">Batman</H1> <H 1 class="merah" id="beda">Jogja</H 1 >
Pada contoh diatas id beda hanya dapat digunakan untuk selector tag HI, untuk membuat agar semua tag dapat menggunakan id beda maka pendefinisiannya harus diubah menjadi: *#beda {font-style: italic;}