Object styles applied to page items determine the class name of containing divs in html and epub output from InDesign. Object styles need not apply any formatting at all, even though this is their primary use in InDesign. They may instead be used to identify certain content by name both in InDesign and in html output generated by InDesign. This utility of object styles goes beyond assigning a distinct class name to a single text frame’s content upon html export. It is possible to cause uniquely named, hierarchically nested divs to be created in the html output. These divs bear class names based on applied object styles like so:
Applying object styles programmatically using ExtendScript can be very useful in some circumstances. The script, applyObjectStyleByParaStyle.jsx, serves as a simple demonstration. This script acts on the active InDesign document. It prompts the user to select a target paragraph style and an object style in the active document. The script applies the selected object style to every text frame in the document that has its first paragraph styled with the target paragraph style.