Home >Web Front-end >HTML Tutorial >What is the code tag in HTML for? Learn about the specific usage and definitions

What is the code tag in HTML for? Learn about the specific usage and definitions

寻∝梦
寻∝梦Original
2018-08-16 17:40:376302browse

What is the code tag in HTML for? Learn about the specific usage and definitions. This article mainly explains the uses and definitions of some cade tags in HTML, as well as the global attributes and event attributes supported by the code tag in HTML

The definition and usage of the code tag in HTML:

tag is used to represent computer source code or other machine-readable text content.

Writers of software code have become accustomed to a particular style of textual representation when writing source code. The tag is designed for them. The text contained within this tag will be displayed in a fixed-width, teletype-style font (Courier), which should be very familiar to most programmers and users of W3School.

The tag should only be used on content that represents computer program source code or other machine-readable text. Although the <code> tag usually just changes the text to a fixed-width font, it implies that the text is source code. Future browsers may add other display effects. For example, the programmer's browser might look for the <code> fragment and perform some additional text formatting, such as special indentation of loops and conditional statements.

Tip: If you just want the effect of using a monospaced font, please use the tag. Or, if you want to display programming code within text that is strictly limited to a fixed-width font format, use the

 tag. 

What is the code tag in HTML?

This is the code element in HTML, the content written in the code element (generally considered to be in HTML format Language) will not be processed by the browser as an HTML language, but will be considered as text and displayed independently as source code with angle brackets. The tag is used to represent computer source code or other machine-readable text. contents.

tag supports html global attributes and html event attributes, as follows:

Format:

Computer code

This is an example:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>html< code>计算机代码标签_PHP笔记</title>
</head>
<body style="font-size:28px;">
<code>计算机代码</code><br />
<em>强调文本</em><br>
<strong>加粗文本</strong><br />
<dfn>定义项目</dfn><br />
<samp>计算机样本</samp><br />
<kbd>键盘输入</kbd><br />
<var>变量</var>
</body>
</html>

Run result:

What is the code tag in HTML for? Learn about the specific usage and definitions

Computer code label html No. 1" title="html< ; code>Computer code label html" >Computer code label" alt="" width="480" height="262" />

【Related recommendations】

What is the lang attribute in HTML for? What does the lang attribute in HTML do?

#What are the new structural elements in HTML5? Usage of new structural elements in HTML5 (recommended)

The above is the detailed content of What is the code tag in HTML for? Learn about the specific usage and definitions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn