รหัส

ตัวอย่างการแสดงโค้ดแบบต่างๆ

ไวยากรณ์ต่างๆ ในโค้ดบล็อกที่มีการปิดกั้น

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;
}