Adjust margins through CSS-sheet in DTTG?

Hi all,

I am working on customizing CSS-sheets for DTTG for markdown documents in preview. If I add CSS in the menu - most of it works. However, it doesn’t seem to adjust the margins on the side.

I add the following:

body {
    font-size: 9pt;
    font-family: 'Baskerville', sans-serif;
    color: black;
    background-color: white;
    line-height: 1.4;
    text-align: justify;
    margin: 0 50px;
    word-break: keep-all;
    overflow-wrap: break-word;
    hyphens: none;
    font-weight: 500;
    word-spacing: -0.05em;
}

However, whatever arbitrary number I give the “margin 0 50 px”, the actual margin in DTTG stays the same. This is also true when I change the px to a percentage.

This gives the question - is it possible to adjust the margins through CSS in DTTG?

1 Like

The margin setting in the OP is ok, in my opinion. 0 is always a syntactically correct length, effectively setting the value to zero in all dimensions. And I do not see any relation to margin-collapse here, that’s about collapsing margin-top and margin-bottom. The issue is with margin-left and margin-right. (BTW: MDN is, in my opinion, a better reference than W3Schools).

What I do see, however, is some weird (or at least unexpected and undocumented) behavior of DTTG in handling the stylesheets. If one converts an MD document to “formatted note” (the closest one can get to pure HTML), it contains three verbatim style definitions. The first of which uses body { ... margin: <something> !important}. Which is, in my not very humble opinion, not a nice thing to do.

To answer @Joris2112’s question: margin: 0 50px !important; should do what you want.

@aedwards: The right thing to do would be to never use !important; in the internal styles. It is counter-intuitive, not documented, and causes problems with user-defined styles. As just seen.

1 Like

I’m not a CSS guy, but from the CSS specification (the link posted by @rmschne):

image

Then should be “margin: 0px 50px”.

Have you tried this format, @Joris2112?

As I said before: a 0 without dimensions is not a problem in CSS. the issue here is another one, namely that DTTG forces its own margins on the users without letting them know.

Oh, the link posted by @rmschne is anything but the CSS specification. That one is at the W3C.

Is the information at the link I gave wrong? My intention was not to give a link to the Standard, but to something I thought helpful. If wrong or not helpful, let me know and I’ll delete my post.

It’s not wrong per se. It just is not very helpful, imo. They only give examples, and those obviously convey the wrong idea that all values must have dimensions. Not to mention that px is not necessarily the most sensible dimension in 2023.

That’s why I suggest using MDN for all references to Web stuff. It’s up to date and complete.

As declared “not helpful” (which I don’t completely agree with, but …). Gone.

Thank you so much @chrillek @rfog

I am a beginner just starting to testing out CSS. It appears that it indeed does work, but only on the body of the text. As my texts are almost completely in unordered lists, it seems that I had to apply it specifically on the lists as well. I did some testing and modifications and now it works indeed.

CSS is hard than I thought. So many options…

You’ve seen the series on Markdown and CSS here?

Also, I suggest fiddling around with it in DT. It’s far easier to convert your MD to HTML, open that in a browser and use the browser’s developer tools to play around with CSS.