Add custom HTML attributes

You can add custom HTML attributes to your final HTML, if you’ll be using the HTML in your own processes later – these attributes will also be included in your EPUB file. For example, you can customize the ID for a section, or you can add special role attributes to certain paragraphs so that your EPUB conforms to your company’s internal specification.

To add a custom attribute, use a processing instruction, like this:

  1. Find the paragraph that you want to add custom attributes to, and insert a new “HED Processing instruction” paragraph below it (for more details on how to do this, see “Add special layout instructions”).

  2. In your processing instruction paragraph, type the text ATTRS=.

  3. Next, type the attribute name, followed by a colon, and then the attribute value.

  4. To add more custom attributes, type a semi-colon, and then type the next attribute name, followed by a colon, and then the attribute value, and so on.

To add a custom attribute to a wrapper, insert the processing instruction paragraph after either the wrapper “start” or “end” paragraphs. (See “Customize the design of specific paragraphs, wrappers, or sections” for an example of what this looks like.)

To add a custom attribute to an entire section, insert the processing instruction paragraph after the section start paragraph. (See “Customize the design of specific paragraphs, wrappers, or sections” for an example of what this looks like.)

Using the SCOPE-BODY Option

You can also apply attributes to your entire document, by using the SCOPE-BODY option in your ATTRS processing instruction. This will apply the selected attribute to the main container element of your manuscript, rather than being applied to the immediately preceding element. To do this:

  1. Type your ATTRS processing instruction, as described above.

  2. After the custom attribute value, but before the closing semi-colon, type: SCOPE-BODY.

Your attribute will now be applied to the body element.

In this processing instruction, we’re overriding the running header text with our own custom text. You can read more about this code snippet in “Custom Styles Library”.

Note that the SCOPE-BODY option must be invoked for each attribute that you want to apply to the body. For example, in the image below, because only the “data-author-name” attribute invokes the SCOPE-BODY option, only that attribute will be applied to the entire body, and the “id” attribute will be applied to the immediately preceding element (in this case, the chapter title) as usual.


Add Roman Text After Italicized Text, in a Locked Chapter
List of Hederis Word Styles
Getting Started
Step-by-Step Guide
File Management, Uploads, and Downloads
Working with Book Text
Design
Paging
Images
Validation and Preflight
Groups and Billing
How Do I…
Appendix