HTML code

HTML Code <code> tag is used to define computer code in an HTML document. The text in this tag is applied with font-family of monospace.

Example

A simple Code element is shown in the following example.

index.html

Note: HTML Code element starts with the tag <code> and ends with an end tag </code>.

ADVERTISEMENT

Default CSS for HTML <code>

By default, following CSS properties are set for a Code element.

font-family: monospace;

Inline Style for HTML Code Element

We can change the style of Code element through inline styling using style attribute.

In the following example, we have set the color to red for the Code element.

index.html

Apply CSS for HTML Code Element

We can apply CSS for all Code elements using the code tag name.

index.html

Conclusion

In this HTML Tutorial, we learned about HTML <code> tag and went through different examples that cover defining an HTML Code element, and styling it.