Skip to content

Instantly share code, notes, and snippets.

@atriple
Last active December 19, 2019 04:37
Show Gist options
  • Select an option

  • Save atriple/972433fb0d2b74d1ec8de09dac58438c to your computer and use it in GitHub Desktop.

Select an option

Save atriple/972433fb0d2b74d1ec8de09dac58438c to your computer and use it in GitHub Desktop.
CSS syntax in quick

General Syntax

Selector { Ruleset } with ruleset generally written as : property: value;, remember the semicolon(;)!

Example :

h1 {
 color: blue;
}

Embedding CSS

  • Inline : <h1 style="color:blue;">, no need to use selector for this
  • Internal : Using <style>...</style>
  • External : <link rel="stylesheet" href="style.css">

Useful for Pros

The Almighty Border Box

html {
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

Normalize.css

https://github.com/necolas/normalize.css

Hierarchy Operators

Given a and b as general element/selector

@media

https://www.w3schools.com/cssref/css3_pr_mediaquery.asp

@media not|only mediatype and (mediafeature and|or|not mediafeature) {
  CSS-Code;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment