Inline code
A short piece of code, a file name, a key or a value inside a sentence: <code class="code">student_id</code>, monospace at 0.88 em on --bg-recessed.
Usage
Use it when
- Naming code, commands, file names, field names or exact values someone will type:
student_id,npm run build,grades.csv. - Showing a short code people copy by reading it (an enrolment key in instructions).
Use something else when
- More than one line of code, or code people copy with a button: use Code block.
- A value people copy with one press: use Copy button.
- A keyboard shortcut: use Keyboard key.
- A status word or category: use Badge.
Where it goes. Inline, inside running text, helper text, table cells and prose. It inherits the size of the text around it (0.88 em), so it works in body text and in footnotes alike. Long values wrap like words; avoid them in narrow phone columns.
Examples
Export your grades as grades.csv, then make sure the first column is student_id. Run npm run import to load them.
<p class="measure" style="font: var(--type-body); color: var(--text-default);">Export your grades as <code class="code">grades.csv</code>, then make sure the first column is <code class="code">student_id</code>. Run <code class="code">npm run import</code> to load them.</p>
DB-2026.
<div class="field" style="max-width: 360px;"> <label class="field__label" for="ic-key">Enrolment key</label> <div class="control"><input id="ic-key" placeholder="DB-2026" aria-describedby="ic-key-help"></div> <span class="field__help" id="ic-key-help">Your lecturer shared it, for example <code class="code">DB-2026</code>.</span> </div>
Anatomy
| Part | What it is |
|---|---|
code.code | Required. A <code> element. --mono at 0.88 em, --text-strong on --bg-recessed, 6 px radius, 1 px by 6 px padding. |
Motion and microinteractions
- None.
Accessibility
- Use the
<code>element; screen readers can announce it as code and keep the exact characters. - Do not rely on the monospace look alone to mark something as literal; say "type" or "enter" in the sentence.
- Contrast:
--text-strongon--bg-recessedis well above 4.5:1 in both themes.
Do and don't
Do
- Use it for exact strings someone types or reads back.
- Keep it short; move anything longer to a code block.
Don't
- Use it for emphasis or for product names.
- Put buttons or links inside it.