reading-notes

How CSS is Structured

Reading

Applying CSS to HTML

<!DOCTYPE html>
<html lang="en-GB">
  <head>
    <meta charset="utf-8" />
    <title>My CSS experiment</title>
    <style>
      h1 {
        color: blue;
        background-color: yellow;
        border: 1px solid black;
      }

      p {
        color: red;
      }
    </style>
  </head>
  <body>
    <h1>Hello World!</h1>
    <p>This is my first CSS example</p>
  </body>
</html>

Selectors

h1
a:link
.manythings
#onething
*
.box p
.box p:first-child
h1, h2, .intro

Properties and Values

Shorthands

/* In 4-value shorthands like padding and margin, the values are applied
   in the order top, right, bottom, left (clockwise from the top). There are also other
   shorthand types, for example 2-value shorthands, which set padding/margin
   for top/bottom, then left/right */
padding: 10px 15px 15px 5px;

  /* the above is equivalent to these four lines of code */
padding-top: 10px;
padding-right: 15px;
padding-bottom: 15px;
padding-left: 5px;