There’s no exact rule when it comes to spacing, but a few important points to keep in mind are consistency, hierarchy and grouping like things together.
Where possible, and where it makes sense, ensure your spacing is consistent. It makes a page look polished, enhances the flow and assists with readability. For example, all spacing between type should be consistent, unless there’s something that needs to be pulled out for prominence (see Hierarchy).
Spacing plays a role in page hierarchy and can draw particular elements to the user’s attention. For example, a page title might have lots of space around it to make it more prominent. On the other hand, paragraphs won’t require the same amount of space as a title, as they aren’t the focus of a page, and having a large amount of space around each paragraph would disrupt the flow of the page.
Group like things together
If a title is related to a paragraph of body copy, then they should be spaced in a way that suggests this. If there’s a video on the same page that doesn’t relate to this content, this should be spaced further away, but a caption for the video should be placed nearby, and so on.
Reviewed 20 July 2020