Semantics
A section whose content represents a fragment of computer code.
Additional info from the ARIA specification
The primary purpose of the code role is to inform assistive technologies that the content is computer code and thus might require special presentation, in particular with respect to synthesized speech. More specifically, screen readers and other tools which provide text-to-speech presentation of content SHOULD prefer full punctuation verbosity to ensure common symbols (e.g., "-") are spoken.
Abstract Role
StructureRepresents a non-interactive part of a page that organizes content into coherent units.
Content Categories
Phrasing ContentAn element that typically appears inline and provides semantic meaning to text content.
Allowed Descendants
Phrasing Children Allowed
Usage
Allowed HTML elements
Implicit semantics
These elements have the role semantics by default, without needing to set the role attribute. Reach for elements with native semantics first when choosing how to implement a role in your content.
code
Explicitly allowed
- None
Elements that can have any role
abbr[role=code]address[role=code]b[role=code]blockquote[role=code]canvas[role=code]cite[role=code]custom-element[role=code]data[role=code]del[role=code]dfn[role=code]div[role=code]em[role=code]figure[role=code]i[role=code]ins[role=code]kbd[role=code]mark[role=code]output[role=code]p[role=code]pre[role=code]q[role=code]samp[role=code]small[role=code]span[role=code]table[role=code]tbody[role=code]tfoot[role=code]thead[role=code]time[role=code]u[role=code]var[role=code]