HTML5

タグ(要素)

CODE

  編集:2022.06.24 by T.A.

mdn

コンピューター コードの断片を表す。

この要素を使用できる文脈

フレージング内容が期待される場所。

内容モデル

フレージング内容

text/htmlにおけるタグ省略

どちらのタグも省略不可。

内容属性
解説

マークアップされているコンピューター コードの言語を示すための、正式な方法はない。使用される言語と一緒に CODE 要素をマークしたい著者は、たとえば構文強調表示スクリプトが正しい規則を使用できるように、たとえば要素に "language-" で始まるクラスを追加することによって、class属性を使用できる。

次の例は、句読点を含む、要素名とコンピューター コードをマークアップするために段落で要素が使用できる様子を示す。

<P>The <CODE>code</CODE> element represents a fragment of computer
code.</P>

<P>When you call the <CODE>activate()</CODE> method on the
<CODE>robotSnowman</CODE> object, the eyes glow.</P>

<P>The example below uses the <CODE>begin</CODE> keyword to indicate
the start of a statement block. It is paired with an <CODE>end</CODE>
keyword, which is followed by the <CODE>.</CODE> punctuation character
(full stop) to indicate the end of the program.</P>
開始<CODE>ABCabcij.012*[]漢字</CODE>終了


テスト
HTML:

ここに表示
HTML:

ここに表示
スクリプト:


スクリプト:



表示内容:
表示内容: