Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

W3.CSS Code

Share

How to Display Code

W3.CSS provides classes for displaying code examples and inline code.

You can also use the W3Schools Code Color library to add syntax highlighting.

Display Code

The w3-code class is designed to display comuter code examples:

It displays code in a readable monospace font:

Example

fruits[0] = "Banana";
fruits[1] = "Apple";
fruits[2] = "Mango";
fruits[3] = "Plum";

Try It Yourself »


Inline Code

The w3-codespan class highlights inline code.

Example: The html element defines an HTML page.

Example

The <code class="w3-codespan">html</code> element defines an HTML page.
Try It Yourself »

Display Examples

Use the w3-panel class to display examples inside a styled container.

Example

A list displayed as a card.

  • Jill
  • Eve
  • Adam

Try It Yourself »



Syntax Highlighting

W3Schools provides the w3codecolor.js library for syntax highlighting.

Example

fruits[0] = "Banana";
fruits[1] = "Apple";
fruits[2] = "Mango";
fruits[3] = "Plum";

You can load the library from:

Example

<script src="https:/edu/lib/w3codecolor.js"></script>

When you use w3codecolor.js, you can add language classes to your code blocks.


Highlight JavaScript Code

Add jsHigh to highlight JavaScript code:

Example

<div class="w3-code jsHigh">

  ... JavaScript code ...

</div>
Try It Yourself »

Highlight HTML Code

Add htmlHigh to highlight HTML code:

Example

<div class="w3-code htmlHigh">

  ... HTML code ...

</div>
Try It Yourself »

Highlight CSS Code

Add cssHigh to highlight CSS code:

Example

<div class="w3-code cssHigh">

  ... CSS code ...

</div>
Try It Yourself »

Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@Learn Html

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@Learn Html

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.