Warning Box: When and How to Use It
Use warning boxes to state a specific risk, explain its consequence, and give the safe action before irreversible, costly, regulated, or dangerous work.
A warning box stops a reader before an action that could cause material harm. It is not a general emphasis style. A publishable warning states the risk, the consequence, and the action that avoids or limits the harm.
The live element works because it identifies what can go wrong, explains what will be lost, and gives a safe sequence before the destructive control. “Be careful when deleting” would not be enough: it transfers the risk assessment back to the reader without telling them what careful behavior means.
Why this element matters
Warnings exist to change a decision before harm occurs. A reader following instructions usually concentrates on reaching the promised outcome, so they may skim qualifications that look like ordinary background. A clearly bounded warning interrupts that momentum at the point where the reader still has a choice. It creates a deliberate pause, explains why the pause matters, and supplies a safe next action.
This element serves reader psychology only while authors use it selectively. If routine advice, minor inconvenience, and irreversible loss all receive the same treatment, readers learn that the visual signal rarely matters. They begin to skip it. Overstatement therefore creates the exact failure mode a warning is meant to prevent: the important message is discounted when the stakes are real. The tone must inform, not frighten.
Machine extractability means software can isolate the warning and preserve its meaning outside the surrounding paragraphs. A typed block with a textual warning label and a self-contained body is easier to identify than a red sentence hidden inside a step. The risk–consequence–action structure also survives presentation changes. An automated publishing system can move the content between Markdown, Hugo, and WordPress without inferring which sentence describes harm or what the reader should do.
Follow the element writing rules when mapping the element. Color, an icon, bold text, or a heading named “Important” does not create warning semantics on its own. The words must remain complete when copied as plain text or read without the page’s visual styling.
When to use it
Use a warning when the reader is about to make a choice or perform an action with a foreseeable material consequence. The element is mandatory when the content covers any of these triggers:
- Irreversible action: deletion, overwrite, publication, submission, account closure, or another action that cannot reliably be undone.
- Data loss or exposure: records may be erased, corrupted, disclosed, transferred, or made inaccessible.
- Cost implication: an action starts a charge, renews a commitment, consumes a paid allowance, or creates a cost that is not obvious at the decision point.
- Safety or health risk: following, combining, or skipping an instruction could cause injury, illness, or delayed care.
- Legal or compliance exposure: an action may breach a law, contract, policy, license, retention rule, consent requirement, or regulated approval process.
The trigger, not the author’s preference or the available word count, controls inclusion. If one applies, the warning cannot be shortened into a vague label, moved to a generic disclaimer, or omitted to fit a template. Shorten surrounding explanation first.
Do not use a warning for a useful shortcut, a best practice, a definition, a mild inconvenience, a normal prerequisite, or a reversible error with an obvious recovery. Those are near misses because they may be “important” in everyday language but do not require a stop decision. Put required prerequisites in the procedure, optional improvements in a tip box, and ordinary failure recovery beside the step it repairs.
Do not warn merely because an outcome is undesirable. “Low-quality titles may reduce clicks” is an explanation of performance, not a warning. It becomes warning material only when a nearby action creates a specific, material consequence: for example, changing a live site’s URL structure without redirects can break inbound links and remove indexed destinations. In that case, state the preventive action before the change.
Where to place it
A warning belongs immediately before the earliest action it concerns. “Action” includes a numbered instruction, command, form submission, purchase control, download, recommendation, or decision that a reader may act on. Put the box after enough context to identify the situation but before the first executable instruction. Never reveal the risk after the action, in endnotes, or only in a closing FAQ.
If one warning governs a sequence, place it before the sequence and name its scope: “The next three steps replace the production database.” Do not repeat the same warning inside every step. If a later step introduces a different risk, add a second warning immediately before that step.
A warning may not sit directly beside another callout, a promotional call to action, or a decorative banner. Adjacent boxes compete for attention and can make the warning look like part of a marketing stack. It must not split an instruction from its required input, a claim from its evidence, or a table title from the table. Add a plain transition or restructure the section so the warning clearly qualifies one decision.
Place legal boilerplate according to the applicable policy, but keep the operational warning beside the risky action. Moving the warning into a footer because a disclaimer already exists defeats its purpose.
Anatomy
The rendered element has six semantic regions:
- Severity label: visible text that says this is a warning; it cannot be conveyed by color or an icon alone.
- Specific title: names the decision or hazard, such as “Warning: export records before deletion.”
- Risk: states what action or condition can go wrong.
- Consequence: states the credible result and who or what is affected.
- Action: tells the reader how to avoid, reduce, verify, or escalate the risk before proceeding.
- Position relationship: connects the warning to the next action it governs.
The legend stays as live page text rather than being baked into the image. That keeps every label available to assistive technology and lets the design change without making the specification inaccurate.
Design examples
The current library supports one warning severity: Hugo renders it with type="important". There is no separate caution, warning, danger, critical, or emergency variant. This deliberate simplicity makes author choice consistent and reduces the chance that two writers assign different colors to the same consequence. The tradeoff is that the component cannot visually distinguish recoverable financial loss from immediate physical danger. Authors must state severity in the title and consequence instead of relying on a stronger color.
The gallery therefore tests the one severity under its supported content variations: the default label, a specific custom title, a two-paragraph maximum, and a narrow viewport. These are rendering cases, not different severity levels.
Do not invent severity by adding emoji, all caps, repeated exclamation marks, custom classes, or unsupported type values. If the library later gains multiple levels, their boundaries must be based on consequence and required response, not on how strongly an author feels about the passage.
Parameters
The renderer has only type, title, and body inputs. Risk, consequence, and action are editorial fields inside the body; keeping them explicit in this contract prevents a visually valid callout from publishing incomplete guidance.
| Name | Type | Required | Min/max | Default | Source |
|---|---|---|---|---|---|
type | Enum | Yes | Exactly important | None for this element | Shortcode attribute |
title | Plain string | Yes | 3–9 words; 70 characters | Renderer default is Important, but the warning contract requires a specific title | Shortcode attribute |
risk | Plain Markdown | Yes | 1 sentence; 8–30 words | None | Body, first sentence or clause |
consequence | Plain Markdown | Yes | 1 sentence; 8–35 words | None | Body after the risk |
action | Plain Markdown | Yes | 1–2 sentences; 8–40 words | None | Body after the consequence |
body | Markdown | Yes | 25–90 words; 1–2 paragraphs | None | Shortcode body |
inlineLink | URL plus anchor | No | 0–1 link | Omitted | Body |
position | Document relationship | Yes | One action or one named sequence | Immediately before the governed action | Element placement |
The title should begin with “Warning:” unless a regulated vocabulary requires another explicit severity word. The body can combine risk and consequence in one sentence, but all three jobs must remain identifiable. A link may point to detailed policy or recovery instructions; it cannot replace the immediate safe action.
Syntax and code examples
All three mappings carry the same type, title, and body. The portable directive is the canonical authored shape. Hugo uses the existing callout shortcode. WordPress may implement the same contract as a registered block; a shortcode form is acceptable only where that installation has registered it.
Portable Markdown directive
:::warning{title="Warning: export records before deletion"}
Deleting the workspace permanently removes its stored reports. Export the records you must retain and verify the workspace name before confirming deletion.
:::
Hugo shortcode
{{< callout type="important" title="Warning: export records before deletion" >}}Deleting the workspace permanently removes its stored reports. Export the records you must retain and verify the workspace name before confirming deletion.{{< /callout >}}
Use named parameters together. Do not mix the positional important value with a named title parameter.
WordPress block or shortcode
<!-- wp:amicited/warning {"title":"Warning: export records before deletion"} -->
<p>Deleting the workspace permanently removes its stored reports. Export the records you must retain and verify the workspace name before confirming deletion.</p>
<!-- /wp:amicited/warning -->
[warning title="Warning: export records before deletion"]Deleting the workspace permanently removes its stored reports. Export the records you must retain and verify the workspace name before confirming deletion.[/warning]
Presentation may differ across systems, but the textual severity, risk, consequence, action, and pre-action position must survive the conversion.
Examples
Good: paid reprocessing with overwrite risk
This example names two concrete risks, states both consequences, and supplies actions that prevent them. Its tone is factual: it does not claim the account will be ruined or the data will be unrecoverable if a retained export provides a recovery path.
Bad: risk without guidance
The bad example does not identify the operation, describe the credible consequence, or tell the reader how to proceed safely. “Serious” is an unsupported severity claim, while “at your own risk” shifts responsibility instead of guiding behavior. Replace it with the exact state change, what can be lost or breached, and the check, backup, approval, alternative, or stop condition required before action.
Another failure is over-alarmism: “Never touch this setting or your entire site could be destroyed!” Even if the setting matters, the wording is not bounded by a likely outcome and gives no safe route. Readers who discover that the claim is exaggerated will discount later warnings.
Legal and regulated content
A disclaimer and a warning perform different jobs. A disclaimer defines scope, qualifications, uncertainty, professional status, or the limits of responsibility. A warning identifies a foreseeable hazard at a decision point and changes what the reader should do next. One cannot substitute for the other.
For legal, financial, health, safety, privacy, or other regulated material, keep the approved disclaimer in its required page location and add a warning before any specific action that could create exposure. For example, a general statement that an article is educational does not remove the need to warn before instructing a reader to stop prescribed treatment, transfer regulated data, publish a claim without approval, or accept a recurring charge.
Authors must not improvise legal conclusions inside the warning. Use wording approved by the responsible subject-matter or compliance reviewer, preserve any required terminology, and give the operational action the reader can actually take: pause, obtain consent, retain records, consult a qualified professional, use an approved channel, or escalate for review. A vague “consult the terms” link is insufficient when the page can state the immediate stop condition.
Schema markup and accessibility
A warning box has no dedicated Schema markup
property and should not create a standalone JSON-LD
object. It remains visible content within the enclosing article. When it qualifies a structured procedure, its full text may be included in the relevant step’s visible instruction and corresponding HowToStep.text; it must not become a fake step or exist only in structured data.
Accessible Rich Internet Applications (ARIA) roles communicate interface behavior to assistive technology when native HTML does not provide it. Static warnings present when the page loads should remain in normal document order and do not need role="alert". An alert role causes immediate announcement and is appropriate only when an urgent warning appears dynamically after an interaction. Applying it to every static callout can interrupt screen-reader users and make routine page entry noisy. The current Hugo renderer outputs a labelled <div> without an ARIA role, which is acceptable for a static block when its text and placement carry the meaning.
Color independence means the warning remains recognizable in monochrome, high-contrast mode, a text-only export, and screen-reader output. Use an explicit “Warning:” title and describe severity in words: “permanently deletes,” “starts a recurring charge,” “may expose personal data,” or “requires medical attention.” Do not write “avoid the red option” or rely on an icon’s alternative text to supply the hazard.
Keep the title and body in reading order before the governed action. Links need descriptive anchor text, keyboard access must not depend on the callout, and essential instructions cannot appear only in a screenshot. If a future interactive component allows dismissal, dismissal must not hide a mandatory warning before the action remains available.
Writing rules
Write one specific warning in 25–90 words and no more than two short paragraphs. Use a 3–9-word title, normally beginning with “Warning:”. Name the triggering action or condition, the credible consequence, and the safe response. Put the reason before the rule: readers comply more reliably when they understand what the rule prevents.
Use proportional verbs. “Permanently deletes,” “overwrites,” “charges,” “exposes,” “invalidates,” and “may cause” describe mechanisms or outcomes. “Devastates,” “disastrous,” “terrifying,” and “catastrophic” usually dramatize instead of specifying. State uncertainty honestly when outcome depends on context, and never guarantee safety merely because a reader follows one precaution.
Keep one decision point per box. A short list is acceptable only when several checks must all happen before that one action; otherwise use prose. Do not put promotional copy, benefits, testimonials, jokes, decorative emoji, unrelated tips, a full procedure, a comparison table, several headings, or a call to action inside the warning. Do not hide required instructions behind a link.
Never use the box to shield an unsupported claim, intimidate a reader into buying, or create artificial urgency. If the action is required, keep the action in the main procedure as well as stating the preventive step in the warning. The box changes attention; it does not replace the document’s operational structure.
Post types that use it
The postTypes frontmatter records the registered formats in which warning triggers are foreseeable. In each row, “mandatory” means the author has no discretion once the stated trigger appears; the element cannot be removed or compressed below risk, consequence, and action to meet a length target.
| Post type | Mandatory trigger | Required position |
|---|---|---|
| ultimate guide | The guide includes safety, health, legal, compliance, paid, destructive, or data-handling instructions. | Before the first risky instruction in each independently actionable section. |
| how-to guide | Any step is irreversible, can lose or expose data, starts a cost, creates regulated exposure, or carries a safety or health risk. | After relevant prerequisites and immediately before the affected step or sequence. |
| what-is page | The explanation includes advice a reader could act on in a regulated, medical, safety-sensitive, or legally consequential context. | Before the first actionable recommendation, not inside the definition. |
| product page | A control, purchase, cancellation, migration, deletion, integration, or data use has a material cost or irreversible consequence not obvious from its label. | Beside and before the relevant action or decision; never only in footer terms. |
| category page | Selection advice could create a compatibility, total-cost, safety, health, legal, or compliance consequence. | Before the recommendation or filter choice that exposes the reader to the risk. |
| use-case page | The promoted workflow handles regulated data, automates a consequential decision, incurs cost, or can produce irreversible or unsafe outcomes. | Before the workflow stage or product action that introduces the exposure. |
Other post types may use a warning whenever the same triggers appear. The table defines recurring, non-optional cases; it does not grant an exemption to formats omitted from postTypes.
QA checklist
Before publication, verify all of the following:
- The box names one specific action, condition, or decision that creates the risk.
- The consequence states what can happen and who or what is affected without exaggeration.
- The action tells the reader how to avoid, reduce, verify, stop, or escalate the risk.
- The warning appears before the first governed action and clearly names its scope.
- No tip, promotion, banner, or second warning competes with it directly.
- A mandatory trigger has not been omitted or shortened for layout or word count.
- The
importanttype and specific textual warning title are present. - Severity remains clear without color, icons, images, or surrounding context.
- A static warning does not use an unnecessary alert role; a dynamic urgent warning is announced appropriately.
- Any disclaimer remains separate and does not replace point-of-action guidance.
- Regulated wording and required terminology have the appropriate subject-matter approval.
- Markdown, Hugo, and WordPress mappings preserve the same title, body, and position.
- The body stays within 25–90 words, contains no marketing language, and uses no more than one necessary link.
- Screenshot comments name only the required future captures; no nonexistent image path is rendered.
FAQ
What must every warning box contain? The specific risk, its credible consequence, and the safe action must all be present. The element is incomplete without any one of them.
Can a warning box appear after the risky action? No. It must appear before the reader can act, even when that requires restructuring the surrounding steps.
Does a legal disclaimer replace a warning box? No. The disclaimer defines scope or limitations; the warning changes behavior at a specific decision point. Regulated pages may require both.
Should a warning box use an alert role? Not when it is already present on page load. Reserve the alert role for urgent information introduced dynamically after an interaction.
How many warning boxes can a page contain? Use one per distinct decision point and consolidate warnings with the same target. If warnings dominate the page, restructure the procedure or reconsider whether the action should be offered at all.
A warning box earns its visual prominence only when it prevents a concrete harm. State the risk, consequence, and action calmly, place them before the decision, and preserve that meaning in every output.
More tutorials in this section
Ready to put it into practice?
Free check · 7-day trial · no credit card