standardebooks / web

The source code for the Standard Ebooks website.
https://standardebooks.org
Creative Commons Zero v1.0 Universal
233 stars 60 forks source link

Default margin for figures #200

Closed robinwhittleton closed 1 year ago

robinwhittleton commented 1 year ago

Should figure (as defined in https://standardebooks.org/manual/1.7.0/single-page#7.8.5.2) have a default margin? At the moment we don’t define any margin, and leave it up to the user agent. In browsers (Gecko, WebKit, Blink) this defaults to margin: 1em 40px from the default W3 HTML stylesheet, but we can’t guarantee it I guess.

acabal commented 1 year ago

Yes I suppose we should, since we define margins for other basic elements like <blockquote> and <h#> in core.css. But, if we're going to think about <figure>, then we should sit down and review all of the block level elements that we may have missed the first time around to define default margins for all of them.

robinwhittleton commented 1 year ago

OK, after some research, this is the picture. SE based on either core.css or recommended default styles in SEMOS. UA agents based on default Gecko / WebKit / Blink stylesheets (they seem to agree mostly these days).

Element SE margin and padding UA margin and padding
article - -
aside - -
blockquote margin: 1em 2.5em; margin: 1em 40px;
body - -
dd - margin: 0 0 0 40xp;
div - -
dl - margin: 1em 0;
dt - -
figcaption margin: 1em; -
figure - margin: 1em 40px;
footer margin-top: 1em; -
h1 margin: 3em 0; margin: 0.83em 0;
h2 margin: 3em 0; margin: 0.83em 0;
h3 margin: 3em 0; margin: 1em 0;
h4 margin: 3em 0; margin: 1.33em 0;
h5 margin: 3em 0; margin: 1.67em 0;
h6 margin: 3em 0; margin: 2.33em 0;
header margin: 1em; -
hgroup margin: 3em 0; -
hr margin: 1.5em auto; margin: 0.5em auto;
li - -
nav - -
ol - margin: 1em 0; padding: 0 0 0 40px;
p margin: 0; margin: 1em 0;
section - -
table - -
ul - margin: 1em 0; padding: 0 0 0 40px;
acabal commented 1 year ago

OK, so it looks like we're basically on track with default stylesheets, and 40px means 2.5em for us assuming a 16px font size.

The only thing that might be tricky is <ol>. I think that in the default stylesheet the left margin includes space for the actual numbers. But if we have very long numbers, like Decline and Fall's endnotes, forcing a custom margin may screw up any padding changes the browser might make to fit long numbers. What do you think?

robinwhittleton commented 1 year ago

I’d be happy to leave left/right padding to default on ol/ul. The 40px seems to have been designed to just about allow four digit ol numbers at a default font size.

So, proposal:

  1. Update the manual figure styling to include margin: 1em 2.5em.
  2. Add that to all books in the corpus that have <figure>s.
  3. Add ul, ol { margin-top: 1em; margin-bottom: 1em; } to core.css.
  4. Update the manual glossary styling to include dl { margin: 1em 0; } dd { margin-left: 2.5em; }.
  5. Update all books in the corpus with glossaries to include those styles.

Happy for me to go ahead with that?

acabal commented 1 year ago

Yes, I think that works!

robinwhittleton commented 1 year ago

I was trying to work out why browsers had gone with 40px instead of 2.5em and realised that it’s probably about coping with increased text size. If you’re reading with 5× zoom then the margins on the left and right will appear to be 200px, not 40px. That could, conversely, make it much harder to see the contents of the figure.

So a slight amendment to my proposal: everywhere where I’d written 2.5em I’ll make 40px instead.

acabal commented 1 year ago

OK, that makes sense. Thanks!

robinwhittleton commented 1 year ago
  1. Done in next branch in https://github.com/standardebooks/manual/commit/ee8657ede4b8b600877e20b4e9d58dadda7da2cd
  2. To follow
  3. Done in https://github.com/standardebooks/tools/commit/732c2a1e0f4e4eb2be2f1d720e143dd3910fa0fd
  4. Done in next branch in https://github.com/standardebooks/manual/commit/891f20b7d5cbd14da7f809dccc97d1edcd5019e8
  5. Done in:
robinwhittleton commented 1 year ago

OK, I’ve updated the following repos with the new figure styling. In a few cases there was a little more work to do, but usually just CSS tidying.

So I guess the only thing left to do is to update core.css in every book. I guess you’ve got a nice script to do that?

acabal commented 1 year ago

Yup! I'm updating them all now. Does that wrap it up for this issue?

robinwhittleton commented 1 year ago

Think so 🙂