The Web Dev Guide by Wishtack
  • The Web Dev Guide by Wishtack
  • HTML
    • HTML Tags
    • HTML Attributes
    • Content Formatting
    • Empty Tags vs Content Tags
    • Some Links
  • ECMAScript
    • Some History
    • Language Properties
    • Single-Threaded thus Asynchronous
    • The Event Loop
    • Classes
    • Hoisting is Dead: var vs. let vs. const
    • this & "binding"
    • Arrow Functions
    • Template Strings
    • Syntactic Sugar
      • Spread
      • Destructuring
      • Rest
      • Object Literal Property Value Shorthand
    • Named Parameters
    • Compatibility
  • Tools
    • Node.js
    • NPM
    • Yarn
    • Webpack
    • WebStorm
    • StackBlitz
  • DOM
    • What Is It?
    • Element Selection
    • Element Modification
    • Events
  • Forms
    • The <form> tag
    • Form elements
    • Form validation
  • Networking
    • Fetch Web API
  • CSS
    • Selectors
    • Transforms
    • Transitions
    • Animations
    • Web Animations API
    • Sass
  • Responsive Web Design
    • Viewport
    • Media Queries
    • Grid Layout
    • Flex Layout
    • Frameworks & Libraries
  • Web APIs
  • Testing
    • Unit Testing
    • End to End Testing
  • Security
    • Injection
    • DOM XSS
    • Insecure Direct Object Reference
    • Cross-Site Request Forgery
    • Client vs API Validation
    • API Unauthorized Access and Data Leak
  • More Links
Powered by GitBook
On this page
  • Cascading Style Sheets, Why?
  • CSS is quite powerful
  • How it works
  • 1. Writing CSS
  • 2. Loading CSS

CSS

PreviousFetch Web APINextSelectors

Last updated 6 years ago

Cascading Style Sheets, Why?

HTML has been designed to describe a document's content but not it's display.

Formatting tags (<b>, <br>, <i>) should not be used.

CSS should be used instead.

Separation of Concerns: CSS allows separation of content and design.

CSS is quite powerful

How it works

1. Writing CSS

CSS syntax is basically composed of selectors, properties and values.

selector {

    /* Comment your CSS! */
    property: value;
    ...

}
  • The selector: allows you to select which elements in the page are concerned by this styling.

  • The property: is the the styling property you want to control.

  • The value: is the value you want to set on the property.

Example

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

2. Loading CSS

Except if you are using a framework, CSS is generally loaded using the HTML <link> tag.

<head>
    <link href="/assets/style.css" rel="stylesheet" type="text/css">
</head>

https://codepen.io/davidkpiano/pen/kkpGWj