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 Add special layout instructions, 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 Code 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
File Management, Uploads, and Downloads
Working with Book Text
Design
Paging
Images
Validation and Preflight
Groups and Billing
How Do I…
Appendix
https://docs.hederis.com/docs/custom-attributes/
docs.hederis.com
crawl=CC-MAIN-2020-50
51327
application/http; msgtype=response
sha1:TDSTOH2M65WDF24MGEF5GYEFTR3WW3IG
<urn:uuid:176afa5a-40e8-4f8f-9fee-8294b93495d6>
2020-11-27T23:21:32Z
185.199.110.153
text/html
sha1:FLEGKKK6GP5Y3YSV3WBCMJ6KARGMFLXA
<urn:uuid:a65ac533-9cd9-4007-9456-df56fe833bbe>
https://docs.hederis.com/docs/custom-attributes/
response
<urn:uuid:37c80a91-0192-4f5e-a175-ab270f129a4a>
isPartOf: CC-MAIN-2020-50
publisher: Common Crawl
description: Wide crawl of the web for November/December 2020
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-75.ec2.internal
software: Apache Nutch 1.17 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.2-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/