Change block spacing

  • Author
    Posts
  • #3390159

    unklee
    Member

    Is it possible to change the space between blocks. It used to be easy – just style the paragraph or heading to reduce or increase the top or bottom margin, even make it negative – but that doesn’t seem to work with Gutenberg.

    Is there something I am missing?

    Thanks.

    The blog I need help with is theway21stcentury.wordpress.com.

    #3390468

    macmanx
    Staff

    Try a Spacer Block to add space: https://en.support.wordpress.com/wordpress-editor/blocks/spacer-block/

    For reducing space, that would need to be done via CSS: https://en.support.wordpress.com/custom-design/custom-css/

    #3390476

    unklee
    Member

    Thanks, but what CSS?

    Reducing the paragraph margin or even making it negative seems to have no effect. Is there a way to reduce the block margin? What tags do I need to style?

    #3390486

    macmanx
    Staff

    Try this:

    /* Paragraph spacing */
    .entry-content p {
      margin-bottom: 10px;
      margin-top: 0;
    }
    #3391085

    unklee
    Member

    Yes, that worked, thanks.

    But I don’t know why my code didn’t work. I tried simply styling the paragraph inline, with <p style="margin-top:-30px;"> but it didn’t have any effect.

    I think I did that in the paragraph block using the Code editor. Perhaps I needed to change the block to HTML???

    #3391103

    kokkieh
    Staff

    Adding inline styles to blocks won’t necessarily work, no. In some cases it might actually break the block, as each block is created with pre-defined HTML code that is allowed inside the block, and any other code, even if it’s valid HTML, would be considered invalid as far as the block is concerned.

    This type of change is best done using custom CSS like @macmanx provided above.

    #3391105

    unklee
    Member

    Thanks for the advice. I prefer to use CSS, but sometimes to be quick, or to test something out I use inline styles. I will have to change my habits!! :)

    #3391111

    kokkieh
    Staff

    I hear you. The block editor has caused a lot of us to get used to a new way of doing things :D

You must be logged in to reply to this topic.