Code

Beispiele für verschiedene Codedarstellungen

Verschiedene Syntaxen in umzäunten Codeblöcken

HTML (mit CSS und JS)

<!-- This should highlight as HTML -->
<head>
    <title>Example</title>
    <style>
        /* This should highlight as CSS */
        .test {
          color: red;
        }
    </style>
</head>
<body>
    <p class="test">This is an example of a simple HTML page with one paragraph.</p>
</body>
<script>
  /* This should highlight as JavaScript */
  const helloWorld = 'Hello World';

  function sayHelloWorld() {
    console.log(helloWorld);
    if (false) {
      // Unreachable code.
    }
    return;
  }

  sayHelloWorld();
</script>

CSS

/* This should highlight as CSS */
.test {
  color: red;
}

#test {
  color: green;
}

JavaScript

/* This should highlight as JavaScript */
const helloWorld = 'Hello World';

function sayHelloWorld() {
  console.log(helloWorld);
  if (false) {
    // Unreachable code.
  }
  return;
}

sayHelloWorld();

Inline-Code

Dies ist ein Absatz mit Inline-Code, z. B. <html lang="en"> und console.log('Hello World');. Ein längeres Snippet wie document.onload = function() { console.log('Document load!); }

In HTML verschachtelte Codeblöcke

HTML (mit CSS und JS) in einem <div>

<!-- This should highlight as HTML -->
<head>
    <title>Example</title>
    <style>
        /* This should highlight as CSS */
        .test {
          color: red;
        }
    </style>
</head>
<body>
    <p class="test">This is an example of a simple HTML page with one paragraph.</p>
</body>
<script>
  /* This should highlight as JavaScript */
  const helloWorld = 'Hello World';

  function sayHelloWorld() {
    console.log(helloWorld);
    if (false) {
      // Unreachable code.
    }
    return;
  }

  sayHelloWorld();
</script>

Preisvergleichsportal in einem <div>

/* This should highlight as CSS */
.test {
  color: red;
}

#test {
  color: green;
}

JavaScript in einem <div>

/* This should highlight as JavaScript */
const helloWorld = 'Hello World';

function sayHelloWorld() {
  console.log(helloWorld);
  if (false) {
    // Unreachable code.
  }
  return;
}

sayHelloWorld();

Ein Code-Snippet in einem Switcher-Div mit einem Kurzcode zum Vergleichen

Kleinste seitliche Anzeigenblöcke des Darstellungsbereichs

.new-min-viewport-units {
  --size: 100vmin;
  --size: 100dvmin;
  --size: 100svmin;
  --size: 100lvmin;
}

Größte Seiteneinheiten im Darstellungsbereich

.new-max-viewport-units {
  --size: 100vmax;
  --size: 100dvmax;
  --size: 100svmax;
  --size: 100lvmax;
}

Linienhervorhebung

@import url(https://fonts.googleapis.com/css2?family=Bungee+Spice);

@font-palette-values --colorized {
  font-family: "Bungee Spice";
  base-palette: 0;
  override-colors: 0 hotpink, 1 cyan, 2 white;
}

Mit --colorized als Alias für die Anpassungen wird im letzten Schritt die Palette auf ein Element angewendet, das die Farbschriftfamilie verwendet:

@import url(https://fonts.googleapis.com/css2?family=Bungee+Spice);

@font-palette-values --colorized {
  font-family: "Bungee Spice";
  base-palette: 0;
  override-colors: 0 hotpink, 1 cyan, 2 white;
}

.spicy {
  font-family: "Bungee Spice";
  font-palette: --colorized;
}