Langsung ke konten utama

CSS Introduction

What is CSS?

  • CSS stands for Cascading Style Sheets
  • CSS describes how HTML elements are to be displayed on screen, paper, or in other media
  • CSS saves a lot of work. It can control the layout of multiple web pages all at once
  • External stylesheets are stored in CSS file.

    Why Use CSS?

    CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.

    CSS Solved a Big Problem

    HTML was NEVER intended to contain tags for formatting a web page!
    HTML was created to describe the content of a web page, like:
    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
    When tags like <font>, and color attributes were added to the HTML 3.2 specification, it started a nightmare for web developers. Development of large websites, where fonts and color information were added to every single page, became a long and expensive process.
    To solve this problem, the World Wide Web Consortium (W3C) created CSS.
    CSS removed the style formatting from the HTML page!

    CSS Saves a Lot of Work!

    The style definitions are normally saved in external .css files.
    With an external stylesheet file, you can change the look of an entire website by changing just one file!

    CSS Syntax

    A CSS rule-set consists of a selector and a declaration block:
    CSS selector
    The selector points to the HTML element you want to style.
    The declaration block contains one or more declarations separated by semicolons.
    Each declaration includes a CSS property name and a value, separated by a colon.
    A CSS declaration always ends with a semicolon, and declaration blocks are surrounded by curly braces.
    In the following example all <p> elements will be center-aligned, with a red text color:

    CSS Selectors

    CSS selectors are used to "find" (or select) HTML elements based on their element name, id, class, attribute, and more.

    The element Selector

    The element selector selects elements based on the element name.
    You can select all <p> elements on a page like this (in this case, all <p> elements will be center-aligned, with a red text color):

    The id Selector

    The id selector uses the id attribute of an HTML element to select a specific element.
    The id of an element should be unique within a page, so the id selector is used to select one unique element!
    To select an element with a specific id, write a hash (#) character, followed by the id of the element.
    The style rule below will be applied to the HTML element with id="para1":

    The class Selector

    The class selector selects elements with a specific class attribute.
    To select elements with a specific class, write a period (.) character, followed by the name of the class.
    In the example below, all HTML elements with class="center" will be red and center-aligned:


    Grouping Selectors

    If you have elements with the same style definitions, like this:
     h1 {
        text-align: center;
        color: red;
    }

    h2 {
        text-align: center;
        color: red;
    }

    p {
        text-align: center;
        color: red;
    }

    It will be better to group the selectors, to minimize the code.
    To group selectors, separate each selector with a comma.
    In the example below we have grouped the selectors from the code above:
     h1, h2, p {
        text-align: center;
        color: red;
    }

    CSS Comments

    Comments are used to explain the code, and may help when you edit the source code at a later date.
    Comments are ignored by browsers.
    A CSS comment starts with /* and ends with */. Comments can also span multiple lines:
     p {
        color: red;
        /* This is a single-line comment */
        text-align: center;
    }

    /* This is
    a multi-line
    comment */

Komentar

Postingan populer dari blog ini

Turorial PewDiePie Game on Steroids [PART 1] - Processing

Pada kesempatan kali ini penulis akan membagikan tutorial cara membuat game yang ada pada Google Chrome jika tidak ada koneksi internet. Tapi perbedaannya karakter T Rex diganti dengan PewDiePie dan rintangan Kaktus diganti dengan T - Series, burung Pterodactyl dengan Monetisasi / Demonetisasi YouTube. Langsung saja ke tutorial : Pertama, install aplikasi processing >>  https://processing.org/download/ Estrak dan jalankan aplikasinya Pertama kita buat kelas yang menampilkan tampilan awal dari game. Simpan dengan nama file Game int nextConnectionNo = 1000; Population pop; int frameSpeed = 60; boolean showBestEachGen = false; int upToGen = 0; Player genPlayerTemp; boolean showNothing = false; //images PImage dinoRun1; PImage dinoRun2; PImage dinoJump; PImage dinoDuck; PImage dinoDuck1; PImage smallCactus; PImage manySmallCactus; PImage bigCactus; PImage bird; PImage bird1; ArrayList<Obstacle> obstacles = new Array...

Apa Itu IMK(Interaksi Manusia dan Komputer) ?

Interaksi manusia dan komputer adalah disiplin ilmu yang mempelajari hubungan antara manusia dan komputer yang meliputi perancangan, evaluasi, dan implementasi antarmuka pengguna komputer agar mudah digunakan oleh manusia. Sedangkan interaksi manusia dan komputer sendiri adalah serangkaian proses, dialog dan kegiatan yang dilakukan oleh manusia untuk berinteraksi dengan komputer secara interaktif untuk melaksanakan dan menyelesaikan tugas yang diinginkan. IMK atau interaksi manusia dan komputer adalah suatu ilmu yang sangat berkaitan dengan disain implementasi dan evaluasi dari sistem komputasi iyang interaktif untuk digunakan oleh manusia dan studi tentang ruang lingkupnya,ada interaksi antara satu atau lebih manusia dan satu atau lebih komputasi mesin. Agar komputer dapat diterima secara luas dan digunakan secara efektif, maka perlu dirancang secara baik. Hal ini tidak berarti bahwa semua sistem harus dirancang agar dapat mengakomodasi semua orang, namun kom...