1
\$\begingroup\$

I'm quoting something that has a centered line of text in the source formatting (pg. 175 of the D&D 5e PHB). I initially used the MathJax display style environment $$ like so:

Here’s how to determine a character’s total for a passive check:

$$10 + \text{all modifiers that normally apply to the check}$$

If the character has advantage on the check, add 5. For disadvantage, subtract 5.

>Here’s how to determine a character’s total for a passive check:
>
>$$10 + \text{all modifiers that normally apply to the check}$$
>
>If the character has advantage on the check, add 5. For disadvantage, subtract 5.

However, we generally prefer to avoid MathJax unless it is necessary (like the post contains math) since not all devices support it. So instead I've used the   character to approximately center the line:

Here’s how to determine a character’s total for a passive check:

                         10 + all modifiers that normally apply to the check

If the character has advantage on the check, add 5. For disadvantage, subtract 5.

>Here’s how to determine a character’s total for a passive check:
>
>                         10 + all modifiers that normally apply to the check
>
>If the character has advantage on the check, add 5. For disadvantage, subtract 5.

So while the markdown looks ridiculous, the output nicely matches the source formatting without using MathJax. Is this a better solution than using MathJax to center the line? Are there any accessibility related reasons I should avoid doing this as well?

\$\endgroup\$
2
  • 2
    \$\begingroup\$ No accessibility issue for screen readers; it's just a space. \$\endgroup\$ Dec 14, 2022 at 14:54
  • \$\begingroup\$ Tested simple HTML: doesn't work. See answer below \$\endgroup\$
    – Trish
    Dec 21, 2022 at 10:33

3 Answers 3

9
\$\begingroup\$

Irrespective of accessibility, it just isn't a good solution in general.

Checked my own post on my phone, and using   doesn't work; it was aligned in the desktop browser I was using, but is going to be a crap shoot in other browsers and devices:

enter image description here

I guess there just isn’t a good way to center align text that isn’t MathJax.

\$\endgroup\$
6
  • 3
    \$\begingroup\$ Just out of curiosity, is there a reason other than fidelity to the original typesetting that's pushing for centering? It seems to me like this would be one of those places where one can faithfully quote the text but not perfectly reproduce the typesetting without changing meaning. But I could be missing something? \$\endgroup\$
    – nitsua60 Mod
    Dec 14, 2022 at 14:58
  • \$\begingroup\$ @nitsua60 No, that's it. Real high stakes issue, I know. \$\endgroup\$ Dec 14, 2022 at 14:59
  • 1
    \$\begingroup\$ Okay. (I mean, I'm with you on reproducing typesetting/appearance where feasible. Using italics for spells, bold-italic for things that are bold-italic in the source text, for example. Just wondered if there were something more here.) \$\endgroup\$
    – nitsua60 Mod
    Dec 14, 2022 at 15:01
  • 1
    \$\begingroup\$ As a side-observation: on D&DBeyond they don't center that line, but they do bold it =D dndbeyond.com/sources/basic-rules/… \$\endgroup\$
    – nitsua60 Mod
    Dec 14, 2022 at 15:02
  • \$\begingroup\$ @nitsua60 Winner winner chicken dinner. \$\endgroup\$ Dec 14, 2022 at 15:06
  • 1
    \$\begingroup\$ @nitsua60: It is centered (and not bolded) in the PHB on D&D Beyond, just not in the Basic Rules. \$\endgroup\$
    – V2Blast
    Dec 16, 2022 at 18:43
7
\$\begingroup\$

Unless formatting is important, don't quote formatting

A general rule in quoting is, that formatting is not taken from a text unless it is important. Importance is usually only afforded to properties in the fontset, such as italics, bolding or CAPITAL LETTERS.

Text formatting on the page is usually not deemed essential in qupting, so a quote usually does not care for indentation or center format. The only exception in this is linebreaks, which often are deemed essential, and in some quotations are remarked with // or a similar orthographic solution in case the quote can't contain actual linebreaks.

Center-alignment

MathJax

But if you absolutely must have center format, MathJax allows text with $$\text{center}$$ for $$\text{center}$$

However, MathJax isn't always playing nice with screen readers, and such should be avoided for formatting only.

HTML doesn't work anymore

At some point, basic HTML was disabled from StackExchange, so that <p align="center">test</p>, usually a center-aligned text, is now rendered as follows:

test

In fact, the relevant HTML code isn't visible in the dev-console F12, and likewise the more verbose <p style="text-align:center;">test</p> wouldn't get parsed as formatting but stripped, just like <div align="center">test</div>: A side by side of the first two paragraphs of this section and its view in the dev-console A side-by-side of the edit window of the above text and the dev-console parsing, highlighting the DIV portion and the parsed output when removing the {code}format.

\$\endgroup\$
2
  • \$\begingroup\$ A very-limited subset of HTML does work on the Stack. For the most part, I think the only HTML that works on Stack Exchange are the tags that replicate what you can do with markup, so there isn’t a lot of point to it. But as far as I know, that’s always been the case? \$\endgroup\$
    – KRyan
    Dec 21, 2022 at 20:11
  • \$\begingroup\$ @KRyan indeed, but the number of working HTML for formating is down to bold and italics by now \$\endgroup\$
    – Trish
    Dec 22, 2022 at 0:04
6
\$\begingroup\$

This is zero issue for screenreaders

A screenreader will just treat all those spaces as a space and move to the next text it has to read aloud, so it won’t cause any problems for those who rely on them.

Centering text is probably not an accessibility problem

Ignoring (for the moment) the “bug” you found, this is effectively centering. I have never received guidance that centered text is a problem for accessibility, and I have worked a fair amount on accessibility under the direction of accessibility experts (to wit: I would not claim to be one, myself). Accessibility is vast, and frankly it’s not a monolithic agreed-upon thing: there are a lot of suggestions, sometimes contradictory, about many details, once you get beyond the low-hanging fruit of headings, contrast, alt properties, and so on. But the general fact that most people find centering a useful way of “centering” some text is probably a good sign: it may very well improve accessibility, done well.

But of course, this isn’t actually centering the text

As you point out, narrower viewports cause text that is “centered” in this way to look awful, since the line wraps and the “centering” turns into what it actually is: an indent. Worse, this isn’t limited to narrow viewports: different fonts, different font sizes, etc. etc. If someone doesn’t have the Georgia font installed on their system, they’re going to see a different font, and that font’s relative widths will (probably) be different. If Stack Exchange decides to change the font in use—as they have in the past—then everyone’s “centering” will be off.

These problems aren’t really resolvable. Unless Stack Exchange offers proper centering, we don’t have it.

\$\endgroup\$
2
  • \$\begingroup\$ Centered text can be an accessibility problem. It's usually fine for a line or two but centered paragraphs are harder to read than left justified ones. \$\endgroup\$
    – Laurel
    Dec 21, 2022 at 20:05
  • \$\begingroup\$ @Laurel Oh, fair, didn’t think of entire paragraphs. Though I’d caution that a lot of the research on readability... leaves a lot to be desired. I haven’t investigated centering on this, per se, but a lot of the evidence for or against the “ragged right” vs. justified text is... poorly replicated, say. \$\endgroup\$
    – KRyan
    Dec 21, 2022 at 20:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .