if condition in css w3schools code example

Example 1: js if else

If - Else Statements
if (condition) {
// what to do if condition is met
} else {
// what to do if condition is not met
}

Example 2: how to write if condition in css

$type: monster;
p {
  @if $type == ocean {
    color: blue;
  } @else if $type == matador {
    color: red;
  } @else if $type == monster {
    color: green;
  } @else {
    color: black;
  }
}

Example 3: javascript if else

/* Shorten if-else by ternary operator*/
const go = "yes"
let race = null

race = go === "yes" ? 'Green Light' : 'Red Light';

Tags:

Css Example