Terminal & Keyboard Semantics
Four elements mark up different kinds of computer-related text: <kbd> for user input, <samp> for program output, <code> for code fragments, and <pre> for preformatted blocks.
Typical Dev Workflow
User types
Run the test suite with npm test — or press Ctrl+T in VS Code.
Terminal shows
$ npm test
> myapp@1.0.0 test
> vitest run
✓ src/utils/format.test.ts 3 passed (12ms)
✓ src/api/client.test.ts 5 passed (34ms)
Test Files 2 passed (2)
Tests 8 passed (8)
Start at 10:23:44 AM
Duration 1.28s
Error from linter
Fix this before committing:
error Expected indentation of 2 spaces but found 4 indent
src/components/Button.tsx:42:5
Actual code fragment
import { useState } from 'react';
export function Counter() {
const [n, setN] = useState(0);
return ;
}
Quick Reference
| Element | Meaning | Typical Render |
|---|---|---|
<kbd> | Keyboard input | Enter |
<samp> | Sample program output | OK |
<code> | Inline code | const x = 1; |
<pre> | Preformatted block | preserves whitespace |
Use <pre><code>...</code></pre> for syntax-highlighted code blocks — <pre> handles whitespace, <code> marks the content as code. Don't nest <pre> inside <samp> or vice versa; use one or the other.