Breaking News

Kamis, 18 November 2010

Cascading Style Sheets (Css)

Pertemuan IX

Cascading Style Sheets (CSS)

  • CSS adalah suatu bahasa yang digunakan untuk mengatur tampilan suatu website, baik tata letaknya, jenis huruf, warna, dan semua yang berhubungan dengan tampilan.
  • Pada umumnya, CSS tu digunakan untuk menformat halaman web yang ditulis dengan HTML
CSS

3 Cara Implementasi CSS

  • Inline Style
  • Internal Style Sheet atau Embed Style
  • External Style Sheet
  • Menjadi atribut dalam tag HTML
  • Atributnya adalah style
  • Cara pendefinisiannya adalah
style="property-1 :nilai ; property-2:nilai;….property-n:nilai"


Contoh 1;

<html>

<head>

<title>Test CSS Inline Style 1</title>
</head>

<body style="color:blue; background-color:yellow">

<p style="text-align:center;text-transform:uppercase;

color:red;font-weight:bold">Pemrograman</p>Web

</body>

</html>












    
Contoh 2

<html>

<head>

<title>Test CSS Inline Style 2</title>

</head>

<body>

<a href="http://www.google.com">Google</a><br>

<a href="http://www.google.com" style="text-decoration:none">Google</a>
</body>

</html>

   
Internal Style Sheet

  • Style yang diletakkan dalam tag HEAD
  • Cara pendefinisiannya adalah;
    <style type="text/css">

    …

    …

    </style>

  • Contoh;
Contoh CSS Internal 1


<html>

<head>

<style type="text/css">
h1 {background-color:Blue;}

p {background-color:red;}

</style>

</head>

<body>

<h1>Header berlatar belakang</h1>

<p>Paragraph dengan latar belakang</p>

</html>












 
Contoh 2


<html>

<head>

<style type="text/css">

p.serif{font-family:"Times New Roman", Times, serif}

p.sansserif{font-family:Arial, Helvetica, sans-serif}

</style>

</head>
<body>

<h1>CSS font-family</h1>

<p class="serif">This is a paragraph, shown in the Times New Roman font.</p>

<p class="sansserif">This is a paragraph, shown in the Arial font.</p>

</body>

</html>





External Style Sheet

  • Style CSS yang berada terpisah pada sebuah file .css
  • Dipanggil dari dalam dokument HTML
  • Format penulisan memanggil file .css
< link rel="StyleSheet" href="namafile.css" type="text/css">

  • Contoh;




Contoh External Style




  • File .css nama file = paragraf_warna.css

  • File HTML
<html>

<head>
<title>title/judul halaman website anda</title>
<link rel="StyleSheet" href="paragraf_warna.css" type="text/css">
</head>
<body>
<p>Contoh paragraf yang berwarna merah</p>
</body>
</html>

 

Tidak ada komentar:

Posting Komentar