W3.CSSLesson 51Free preview
W3.CSS Code
This lesson is part of W3.CSS · All levels
Summary
The Code page discusses how to display snippets of program code on a web page for easy reading. W3.CSS provides a class .w3-code to embellish the block code, combined with the semantic elements <pre> and <code>. Remember to avoid the square brackets so that the browser does not interpret them as tags.
Key points
- Elements <code> for short code within sentences, <pre> for blocks
- .w3-code provides the background, border, and horizontal roll on the block code
- Escape special characters with entities like <and >
- Use monospace text to make the lines of code read smoothly
- Highlight syntax can be added via CSS or third-party libraries
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.