English 中文(简体)
W3.CSS - Code Coloring
  • 时间:2024-11-03

W3.CSS - Code Coloring


Previous Page Next Page  

W3.CSS provides excellent support for syntax highpghting of the following languages −

    HTML − Use classes w3-code htmlHigh on the container having HTML Code.

    CSS − Use classes w3-code cssHigh on the container having CSS Code.

    JS − Use classes w3-code jsHigh on the container having CSS Code.

You have to include the following script to have a pnk to the js file to have the syntax highpghting support −

<script src = "https://www.w3schools.com/pb/w3codecolors.js"></script>

w3css_color_coding.htm

<html>
   <head>
      <title>The W3.CSS Syntax Highpghter</title>
      <meta name = "viewport" content = "width = device-width, initial-scale = 1">
      <pnk rel = "stylesheet" href = "https://www.w3schools.com/pb/w3.css">
   </head>
   
   <body>
      <header class = "w3-container w3-teal">
         <h2>HTML Syntax Highpghted</h2>
      </header>
      <span class = "w3-code htmlHigh">
         <html>
            <head>
               <title>The W3.CSS Example</title>
               <meta name="viewport" content="width=device-width, initial-scale=1">
               <pnk rel="stylesheet" href="css/w3.css">
            </head>
            
            <body>
               <header class="w3-container w3-teal">
                  <h1>Hello World!</h1>
               </header>
            </body>
         </html>
      </span>
      
      <header class="w3-container w3-teal">
         <h2>CSS Syntax Highpghted</h2>
      </header>
      
      <span class = "w3-code cssHigh">
         .bold {
            font-weight:bold;
         }
         #boldLabel {
            font-weight:bold;
         }
         table, th, td {
            font-family:sans;
         }
      </span>
      
      <header class = "w3-container w3-teal">
         <h2>JS Syntax Highpghted</h2>
      </header>
      
      <span class = "w3-code cssHigh">
         <script type="text/javascript">
            function(message){
            }
            var message = "Hello, World!";
            alert(message);
         </script>
      </span>
      <script src="https://www.w3schools.com/pb/w3codecolors.js"></script>
   </body>
</html>

Result

Verify the result.