Code
| Description | Encapsulates a fragment of computer program text, preserving formatting and indicating that the content is intended as code. |
|---|---|
| Namespace | 1.7 |
| Category | inline |
Attributes
Specifies how the element is placed relative to surrounding content (e.g., block-level or inline flow).
Defines the direction of text flow (e.g., left-to-right, right-to-left, or vertical).
Sets the background color for the element’s content area.
Specifies the color of the border around the element.
Indicates the style of the border (e.g., solid, dashed, dotted).
Defines the thickness of the border line in user space units (such as points).
Determines the space between the element’s border (or boundary) and its inner content.
Applies the primary color (fill or stroke) for the text or graphic content.
Main indicator of type. This semantic association allows tools to present and support interaction with the object in a manner that is consistent with user expectations about other objects of that type.
Properties
Differences
Well tagged PDF:
The 'Code' element in Well-Tagged PDF is used to encapsulate programming code or code snippets. It distinguishes code from regular text.
It must preserve formatting and be rendered in a monospaced font, ensuring that indentation and syntax are maintained for accurate content extraction and reflow.
PDFUA:
In PDF/UA, the 'Code' element ensures that code segments are accessible by providing clear semantic identification, which aids in maintaining the correct reading order.
Code blocks should be tagged with additional metadata or alternative text if necessary, to assist users in understanding the programming content through assistive technologies.
Use cases
Code element represents a block of Python code.
Try itInline code snippet within a paragraph
Try itTag Relationships
Permitted Parent Tags
Permitted Child Tags
Click on any tag to view its details.