أمثلة على طرق مختلفة لعرض الرمز
قواعد نحوية مختلفة في مجموعات الرموز المُفصَّلة
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;
}