ตัวอย่างการแสดงโค้ดที่หลากหลาย
ไวยากรณ์ต่างๆ ในโค้ดบล็อกที่มีเครื่องหมาย
HTML (มี CSS และ 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();
โค้ดแบบแทรกในบรรทัด
นี่คือย่อหน้าที่มีโค้ดในบรรทัด เช่น <html lang="en">
และ console.log('Hello World');
ตัวอย่างข้อมูลยาวขึ้น เช่น document.onload = function() { console.log('Document load!); }
โค้ดบล็อกที่ฝังอยู่ใน HTML
HTML (มี CSS และ JS) ใน <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 ใน <div>
/* This should highlight as CSS */ .test { color: red; } #test { color: green; }
JavaScript ใน <div>
/* This should highlight as JavaScript */ const helloWorld = 'Hello World'; function sayHelloWorld() { console.log(helloWorld); if (false) { // Unreachable code. } return; } sayHelloWorld();
ข้อมูลโค้ดภายใน div ตัวสลับที่มีช็อตคอร์ตการเปรียบเทียบ
หน่วยด้านข้างของวิวพอร์ตที่เล็กที่สุด
.new-min-viewport-units { --size: 100vmin; --size: 100dvmin; --size: 100svmin; --size: 100lvmin; }
หน่วยด้านข้างวิวพอร์ตที่ใหญ่ที่สุด
.new-max-viewport-units { --size: 100vmax; --size: 100dvmax; --size: 100svmax; --size: 100lvmax; }
การไฮไลต์บรรทัด
@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;
}
เมื่อใช้ --colorized
เป็นชื่อแทนสำหรับการปรับแต่ง ขั้นตอนสุดท้ายคือการใช้จานสีกับองค์ประกอบที่ใช้ชุดแบบอักษรสี โดยทำดังนี้
@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;
}