CSS 1

Intro

HTML without CSS is like the bare concrete skeleton of a building. We use CSS to style, position and layout the page.

CSS anatomy

Where to write CSS?

There are 3 main ways to incorporate CSS in our page

  1. External CSS using link tag
  2. Internal CSS with style block
  3. Inline CSS

Demo

Some basic properties

  • color
  • background
    • background-color
    • background-image
  • font-size
  • text-align

Exercise

Specificity

The browser calculates which selector will take precedence and be applied on the elements using specificity. usually it's quite intuitive.

  1. !important
  2. inline
  3. Ids
  4. classes
  5. elements

EMMET

EMMET makes it easier to create HTML tags using CSS selector syntax. take a few minutes to familiarize yourself, you won't look back :)

Text properties

  • text-align
  • vertical-align
  • text-decoration
  • font
    • font-size
    • font-weight
    • font-family
  • direction

Display types

  • inline
  • inline-block
  • block
  • none
  • flex
  • grid

The box model

The box model

  1. inline elements are not actual boxes
    • don't accept height/width
    • don't respond well to padding/margin
  2. box-sizing determines how width/height is calculated

CSS units

  • px
  • %
  • em or rem
  • vh, vw vmin, vmax

 

End

CSS 1

By Netcraft