Przykłady różnych wyświetleń kodu
Różne składnie w blokach kodu
HTML (z CSS i 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();
Kod wbudowany
To jest akapit z kodem wbudowanym, np. <html lang="en">
i console.log('Hello World');
. dłuższy fragment, na przykład document.onload = function() { console.log('Document load!); }
.
Bloki kodu zagnieżdżone w HTML-u
HTML (z CSS i JS) w pliku <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>
CSS w pliku <div>
/* This should highlight as CSS */ .test { color: red; } #test { color: green; }
JavaScript w <div>
/* This should highlight as JavaScript */ const helloWorld = 'Hello World'; function sayHelloWorld() { console.log(helloWorld); if (false) { // Unreachable code. } return; } sayHelloWorld();
Fragment kodu w elemencie div przełącznika z shortcodem porównywania
Najmniejsze jednostki po bokach widoku
.new-min-viewport-units { --size: 100vmin; --size: 100dvmin; --size: 100svmin; --size: 100lvmin; }
Największe jednostki po bokach widocznego obszaru
.new-max-viewport-units { --size: 100vmax; --size: 100dvmax; --size: 100svmax; --size: 100lvmax; }
Podświetlanie linii
@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;
}
W przypadku --colorized
jako aliasu dostosowań ostatnim krokiem jest zastosowanie palety do elementu, który używa kolorowej rodziny czcionek:
@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;
}