I am using Indesign CC to create a book on HTML programming. I have used TextFrames to add blocks of code and markup. When I generate an ePub out of it, the code blocks and markup are generated without indentation. Everything is left aligned.

However when I export the textframe as an image, the markup comes with indentation but the file size is way too big and the code is obviously not selectable.

What options do I have here? Here's an example of the kind of code I am dealing with:

    <table border="1">
                <th class="c1">ABC</th>
                <th class="c2">PQR</th>
                <th class="c3">XYZ</th>
  • 2
    The real problem is that ePub is basically HTML, so your code needs to be wrapped in a PRE element in order to maintain your desired spacing and indentation (unless converted to an image). I have zero knowledge of InDesign, and have no way of knowing whether or not there is an option to set blocks of text as preformatted on export, but that's what you need. Commented Nov 21, 2014 at 14:14
  • @StanRogers Great tip. I am trying to use some css to wrap my div's in a <pre> tag. Let's see hwo it goes
    – Hitz
    Commented Nov 21, 2014 at 18:10

1 Answer 1


You need to apply a paragraph style in InDesign. They are not in Window but the panel is located in Type. Shortcut cmd+F11:

enter image description here

Create the paragraph style, double click, go to Indents and Spacing:

enter image description here

Add your desired indent in the First Line Indent:

enter image description here

enter image description here

Taking it a little further. You could unpack the ePub and navigate to your CSS and build a class and apply text-indent. If you do go this route be careful because the output of InDesign will produce multiple CSS classes so you will need to verify that your indention was applied correctly.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.