--- title: Block layout: documentation doc-tab: elements doc-subtab: block breadcrumb: - home - documentation - elements - elements-block meta: colors: false sizes: false variables: true --- {% capture block_example %}
This text is within a block.
This text is within a second block. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean efficitur sit amet massa fringilla egestas. Nullam condimentum luctus turpis.
This text is within a third block. This block has no margin at the bottom.
{% endcapture %} {% capture no_block_example %}
This text is not within a block.
This text isn't within a block either. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean efficitur sit amet massa fringilla egestas. Nullam condimentum luctus turpis.
This text is also not within a block.
{% endcapture %} {% capture block_css %} .block:not(:last-child) { margin-bottom: 1.5rem; } {% endcapture %} {% capture no_block %}

Without block

30%
Primar lorem ipsum dolor sit amet, consectetur adipiscing elit lorem ipsum dolor.

Error

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque risus mi, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum felis venenatis efficitur.
{% endcapture %} {% capture with_block %}

With block

30%
Primar lorem ipsum dolor sit amet, consectetur adipiscing elit lorem ipsum dolor.

Error

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque risus mi, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum felis venenatis efficitur.
{% endcapture %}

The block element is a simple spacer tool. It allows sibling HTML elements to have a consistent margin between them:

{% include elements/snippet.html content=block_example %}

As you can see, the first two blocks have a margin-bottom applied, but not the third one.. That is because Bulma applies a space on all blocks, except the last one. This means you can use as many blocks as you want, the spacing will only appear between them.

Without using block, the HTML elements would have no space between them:

{% include elements/snippet.html content=no_block_example %} {% include elements/anchor.html name="You're already using it" %}

As a matter of fact, you're already using the block without knowing it. Its CSS properties are shared across several Bulma elements and components:

This is thanks to the @extend %block Sass placeholder feature.

Here's how it would look like in comparison:

{{ no_block }}
{{ with_block }}

No matter which Bulma elements and components you are using, and no matter their order, they will have a consistent space between them.

{% include elements/anchor.html name="One line of CSS" %}

As you can see, the CSS of the block is very simple: it applies a margin-bottom on all siblings, except the last one.

{% highlight css %}{{ block_css }}{% endhighlight %}

This prevents the last sibling to add unnecessary space at the bottom.

{% include components/variables.html type='element' %}