• Resolved krapp91

    (@krapp91)


    When I add a paragraph block in Gutenberg and write in some text, there are several options under Typography for ‘font size’. I see ‘Default’, ‘Small’, ‘Normal’, ‘Medium’, ‘Large’, ‘Huge’, and ‘Custom’. Where are these defined? I would like to set Default font size to be 20 px.

    I know I can use CSS to make the font size of p always 20 px but sometimes I don’t want it to be 20px, I just *normally* want it to be 20px. Currently I have to highlight each bit of text I write and change the font to 20px.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @krapp91, you can add custom CSS to change the font size of the default to 20px as follows.

    The custom variant will have font-size set inline so we can safely ignore that. First identify the class names of the small, normal, large and larger variants. It is has-*-font-size, so to preserve their font-sizes, my CSS selector needs to exclude paragraph tags with these classes. So my custom CSS will be:

    p:not([class*="font-size"]) {
      font-size: 20px;
    }
    Thread Starter krapp91

    (@krapp91)

    Thanks @dhruvkb that seems to work for p tags! How would I also apply it to ul and ol? would it be:

    li:not([class*=”font-size”]) {
    font-size: 20px;
    }

    Do you know if there is any way to actually change the styles for the default typography? Your solution works well when the page renders, however within Gutenberg the text still appears to be the wrong font.

    In the case of ul/ol, the class is present on the ul/ol tags and not on li so the corresponding CSS would be

    ul:not([class*="font-size"]) li,
    ol:not([class*="font-size"]) li {
      font-size: 20px;
    }

    The best way to ensure that the editor and the rendered page display identically would be to create a child theme and override the CSS for p, ul/ol and li tags as desired. But that’s slightly more technical route than the above CSS patch so I’ve attached links to the documentation.

    Thread Starter krapp91

    (@krapp91)

    Thanks @dhruvkb that worked for me!

    @krapp91 happy to be of help. Please mark the ticket as resolved if your issue has been fixed. Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Defining the “Default” Typography in Gutenberg’ is closed to new replies.