HTML: h1, h2, h3 indent

On my title page I use H1, h2, h3 except they appear indented when complied to Epub
I thought this in the custom CSS would fix it:
h1, h2, h3, h4, h5, h6 { text-indent: 0em; }
But they are still indented.
Looking in the compiled CSS they are given a class of ps2 which indeed is indented. But when I look at the stylesheets within Scrivener, .ps2 is nowhere to be found.
How do I make my title page UNindented?

Richard

Possiby in the Compile Styles, the Headers are indented in the Style formatting Editor?
Open compiled HTML in a webbrowser and analyse the markup in the Inspector to see what CSS-rules work on those headings.
Overrule specific H#. ps2…
As last resort, use !important before the ;

I think .ps2 stands for Paragraph Style 2, suggesting it’s a class for a <p>, so H1 p.ps2{} might do the trick.

Good luck

There are a few things that stand out as things that might require clarification:

  • The default Ebook compile format would format Heading 1 and Heading 2 styles as centre-aligned by default, without any indenting. (It also has an unusual design choice of making them actually h2 and h4 in the HTML, but that shouldn’t be a factor here, just something to be aware of when looking at the HTML output.)

  • It doesn’t sound to me like what you refer to as, “H1, h2, h3”, are actually that, if you’re getting automatically generated paragraph styles (ps2) as well. Unless you found a bug that is, a style that is classified as having an HTML header level (in the Format ▸ Paragraph ▸ HTML Header Level menu, or as established in the Styles pane in the compile format editor) should not be inserting <p> elements anywhere, or adding paragraph styles to the h# elements.

  • You make reference to using header outline levels for different elements on your title page. That’s a somewhat unorthodox use for this HTML element. Not a big deal, but to speak of good practices that might also solve your problem indirectly, a better approach would be to create a “Book Title” style, and a “Author” style, and whatever else you need, and then format those elements directly in the Styles pane.

    Attempting to exert high level element overrides to the heading elements themselves could have unintended consequences elsewhere, like how chapter headings look, or subsection headings. In short, what it sounds like you are doing is using outlining elements to change the font size on your title page, basically, when in fact using them that way would be like having three nested text items at the top of your Draft folder reading “Name of Book”, then indented below that, “Your Name” and finally nested beneath that, “2021-08-23”. That’s how accessibility tools are going to “see” the document structure of your title page, which isn’t correct. The title page is, if anything, outside of the flow of the outline and a special unstructured page, like dedication or copyright pages.

Looking in the compiled CSS they are given a class of ps2 which indeed is indented. But when I look at the stylesheets within Scrivener, .ps2 is nowhere to be found.

They wouldn’t be, as those are generated on the fly during compile, based on variations in paragraph formatting found throughout the text.

To see these CSS entries you should open your compiled book in Sigil or the Calibre editor. That will also be a much better environment for figuring out issues like this. Instead of setting up rules in the hopes that they work and compiling over and over until something works, you can see the fully exported .css file, and use HTML inspection tools to see exactly which styles are influencing an element. If there is an indent coming through, you’ll find exactly where it comes from, and how to override it, or better know where to change whatever is going on in Scrivener.


Inspect HTML & CSS button in Sigil

Amber, thanks for your reply.

It doesn’t sound to me like what you refer to as, “H1, h2, h3”, are actually that, if you’re getting automatically generated paragraph styles (ps2) as well.

Instead of setting up rules in the hopes that they work and compiling over and over until something works, you can see the fully exported .css file, and use HTML inspection tools to see exactly which styles are influencing an element

Looking at the HTML in Sigil is exactly what I’ve been doing:

<div class="front-matter">
<p id="doc3" class="br"><br /></p>
<h1 class="ps3"><strong><span style="font-weight:600;">BOOK<br />TITLE</span></strong></h1>
<p class="br"><br /></p>
<h3 class="ps3">Subtitle</h3>
<p class="br"><br /></p>
<h2 class="ps3">MY NAME</h2>
</div>

Using Sigil to edit out the class=“ps3” fixes the problem. It looks like a bug to me as the “front-matter” class is not indented so it looks as if that’s what you intended for those the pages.

I’ll either edit in Sigil before I publish or find out how to create my own styles and hope they work.

Thanks again for your time,

Richard

AntoniDol – Yes, I believe it’s a stray paragraph style that’s getting in there. I am using Sigil.

I’ll either edit in Sigil before I publish or find out how to create my own styles and hope they work.
I’ll also look at using !important

Thanks for your time,
Richard

Yeah, that’s where I was hoping Sigil would help trace down where the formatting is coming from. If you inspect the H1 element, and open up the Styles tab, it should show the complete cascade of each selector involved, and what is overriding which. The “Computed” tab will show the ultimate result, of whether there really is a text-indent, etc.

For example, if I create a quick test project with some junk text and a “Heading 1” styled line within it, and inspect that line, here’s the computed CSS for that element (using stock “Ebook” compile format settings):

<h1 class="ps3"><strong><span style="font-weight:600;">BOOK<br />TITLE</span></strong></h1>

Okay, that’s interesting. Somehow you are getting a result that I wouldn’t expect to see. Of course ideally all of this word processor style formatting dump wouldn’t be there and we’d just get something simple like:

<h1 class="heading-1">BOOK<br/>TITLE</h1>

But it’s curious that you are getting an h1 element, without a named style. Are you not using styles at all? If so, I guess that might explain the result you’re getting. If it’s just a “naked” paragraph with an HTML level assigned to it manually, then that would make more sense.

Again though, I think having a “Book Title” style that is set up to look the way it should on its own merit would make way more sense here anyway.

Sorry, I don’t know how insert the computed style information from Sigil in a post.

It’s just an screenshot, you will find an “upload” button to the right of the code formatting button in the post response toolbar, you can link to an image uploaded to your own site with Markdown, if you prefer (that’s what I do).

That said, I don’t know how helpful the computed values will be to anyone that doesn’t have access to your .epub file directly. That just tells you what the layout engine ended up with, and is thus useful for seeing if what you’re looking at is actually an indent and not a margin, padding or something else. What matters is the Styles tab, where you can see all of the selectors that are setting a particular type of formatting come from.

Of course, I did correct my problem by using custom styles–my first time using them.
Thanks again,
Richard