HTML
2.0.html
HTML and CSS
Learn HTML Learn CSS Learn Bootstrap Learn W3.CSS Learn Colors Learn Icons Learn Graphics Learn SVG Learn Canvas Learn How To Learn SassJavaScript
Learn JavaScript Learn jQuery Learn React Learn AngularJS Learn JSON Learn AJAX Learn AppML Learn W3.JSProgramming
Learn Python Learn Java Learn C++ Learn C# Learn R Learn Machine Learning Learn Data Science Learn PandasHTML
HTML Tag Reference HTML Browser Support HTML Event Reference HTML Color Reference HTML Attribute Reference HTML Canvas Reference HTML SVG Reference HTML Character Sets Google Maps ReferenceCSS
CSS Reference CSS Browser Support CSS Selector Reference Bootstrap 3 Reference Bootstrap 4 Reference W3.CSS Reference Icon Reference Sass ReferenceJavaScript
JavaScript Reference HTML DOM Reference jQuery Reference AngularJS Reference AppML Reference W3.JS ReferenceProgramming
Python Reference Java ReferenceExercises
HTML Exercises CSS Exercises JavaScript Exercises SQL Exercises PHP Exercises Python Exercises jQuery Exercises Bootstrap Exercises Java Exercises C++ Exercises C# ExercisesHTML Reference
HTML by Alphabet HTML by Category HTML Browser Support HTML Attributes HTML Global Attributes HTML Events HTML Colors HTML Canvas HTML Audio/Video HTML Character Sets HTML Doctypes HTML URL Encode HTML Language Codes HTML Country Codes HTTP Messages HTTP Methods PX to EM Converter Keyboard ShortcutsHTML Tags
<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>HTML <code> Tag
Example
Define some text as computer code in a document:
<p>The HTML <code>button</code> tag defines a clickable button.</p>
<p>The CSS <code>background-color</code> property defines the background color
of an element.</p>
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The <code>
tag is used to define a piece of computer code.
The content inside is displayed in the browser's default monospace font.
Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS (see example below).
Also look at:
Tag | Description |
---|---|
<samp> | Defines sample output from a computer program |
<kbd> | Defines keyboard input |
<var> | Defines a variable |
<pre> | Defines preformatted text |
Browser Support
Element | |||||
---|---|---|---|---|---|
<code> | Yes | Yes | Yes | Yes | Yes |
Global Attributes
The <code>
tag also supports the Global Attributes in HTML.
Event Attributes
The <code>
tag also supports the Event Attributes in HTML.
More Examples
Example
Use CSS to style the <code> element:
<html>
<head>
<style>
code {
font-family:
Consolas,"courier new";
color: crimson;
background-color: #f1f1f1;
padding: 2px;
font-size:
105%;
}
</style>
</head>
<body>
<p>The HTML
<code>button</code> tag defines a clickable button.</p>
<p>The CSS
<code>background-color</code> property defines the background color of an
element.</p>
</body>
</html>
Try it Yourself »
Related Pages
HTML tutorial: HTML Text Formatting
HTML DOM reference: Code Object
Default CSS Settings
Most browsers will display the <code>
element with the following default values:
Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Thank You For Helping Us!
Your message has been sent to W3Schools.
Copyright 1999-2021 by Refsnes Data. All Rights Reserved.
W3Schools is Powered by W3.CSS.

HTML and CSS
Learn HTML Learn CSS Learn Bootstrap Learn W3.CSS Learn Colors Learn Icons Learn Graphics Learn SVG Learn Canvas Learn How To Learn SassJavaScript
Learn JavaScript Learn jQuery Learn React Learn AngularJS Learn JSON Learn AJAX Learn AppML Learn W3.JSProgramming
Learn Python Learn Java Learn C++ Learn C# Learn R Learn Machine Learning Learn Data Science Learn PandasHTML
HTML Tag Reference HTML Browser Support HTML Event Reference HTML Color Reference HTML Attribute Reference HTML Canvas Reference HTML SVG Reference HTML Character Sets Google Maps ReferenceCSS
CSS Reference CSS Browser Support CSS Selector Reference Bootstrap 3 Reference Bootstrap 4 Reference W3.CSS Reference Icon Reference Sass ReferenceJavaScript
JavaScript Reference HTML DOM Reference jQuery Reference AngularJS Reference AppML Reference W3.JS ReferenceProgramming
Python Reference Java ReferenceExercises
HTML Exercises CSS Exercises JavaScript Exercises SQL Exercises PHP Exercises Python Exercises jQuery Exercises Bootstrap Exercises Java Exercises C++ Exercises C# ExercisesHTML Reference
HTML by Alphabet HTML by Category HTML Browser Support HTML Attributes HTML Global Attributes HTML Events HTML Colors HTML Canvas HTML Audio/Video HTML Character Sets HTML Doctypes HTML URL Encode HTML Language Codes HTML Country Codes HTTP Messages HTTP Methods PX to EM Converter Keyboard ShortcutsHTML Tags
<!--> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>HTML <code> Tag
Example
Define some text as computer code in a document:
<p>The HTML <code>button</code> tag defines a clickable button.</p>
<p>The CSS <code>background-color</code> property defines the background color
of an element.</p>
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The <code>
tag is used to define a piece of computer code.
The content inside is displayed in the browser's default monospace font.
Tip: This tag is not deprecated. However, it is possible to achieve richer effect by using CSS (see example below).
Also look at:
Tag | Description |
---|---|
<samp> | Defines sample output from a computer program |
<kbd> | Defines keyboard input |
<var> | Defines a variable |
<pre> | Defines preformatted text |
Browser Support
Element | |||||
---|---|---|---|---|---|
<code> | Yes | Yes | Yes | Yes | Yes |
Global Attributes
The <code>
tag also supports the Global Attributes in HTML.
Event Attributes
The <code>
tag also supports the Event Attributes in HTML.
More Examples
Example
Use CSS to style the <code> element:
<html>
<head>
<style>
code {
font-family:
Consolas,"courier new";
color: crimson;
background-color: #f1f1f1;
padding: 2px;
font-size:
105%;
}
</style>
</head>
<body>
<p>The HTML
<code>button</code> tag defines a clickable button.</p>
<p>The CSS
<code>background-color</code> property defines the background color of an
element.</p>
</body>
</html>
Try it Yourself »
Related Pages
HTML tutorial: HTML Text Formatting
HTML DOM reference: Code Object
Default CSS Settings
Most browsers will display the <code>
element with the following default values:
Report Error
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Thank You For Helping Us!
Your message has been sent to W3Schools.
Copyright 1999-2021 by Refsnes Data. All Rights Reserved.
W3Schools is Powered by W3.CSS.
