Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Code Markup in HTML | Advanced Text Formatting Elements
Introduction to HTML

book
Code Markup in HTML

You can use the <code> element to mark up code in HTML.

html

index.html

copy
<p>To display a message in the console, you can use the following code:</p>
<pre><code>console.log("Hello, world!");</code></pre>

Notice that the <code> element is nested inside the <pre> element. The <pre> element represents preformatted text and is typically displayed in a fixed-width font to preserve both spaces and line breaks.

You can also use the <code> element to mark up inline code like this:

html

index.html

copy
<p>
To display a message in the console, you can use the
<code>console.log()</code> function.
</p>

You can also use the <kbd> element to mark up keyboard input. The <kbd> element represents user input and is typically displayed in a monospace font to distinguish it from regular text.

html

index.html

copy
<p>To save the file, press <kbd>Ctrl</kbd>+<kbd>S</kbd>.</p>

Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 4. Kapitel 3

Spørg AI

expand
ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

some-alt