# MD076 - List item spacing should be consistent Aliases: `list-item-spacing` ## What this rule does Enforces consistent blank-line spacing between consecutive items in a list. Within each list, every inter-item gap must follow the same style: either all gaps have a blank line (**loose**) or none do (**tight**). ## Why this matters - **Visual consistency**: Mixing tight and loose gaps in a single list looks accidental and is harder to read. - **Rendered output**: CommonMark renders a list as loose when blank lines separate its items or separate direct child blocks within an item. Removing inter-item blanks cannot make a multi-paragraph list tight, and formatters such as Prettier restore those blanks. ## Examples ### Tight list (no blank lines between items) #### Correct ```markdown - Item 1 - Item 2 - Item 3 ``` #### Incorrect (mixed spacing) ```markdown - Item 1 - Item 2 - Item 3 ``` ### Loose list (blank line between every item) #### Correct ```markdown - Item 1 - Item 2 - Item 3 ``` #### Incorrect (mixed spacing) ```markdown - Item 1 - Item 2 - Item 3 ``` ### Ordered lists The rule applies equally to ordered lists: ```markdown 1. First 2. Second 3. Third ``` ## Configuration ```toml [MD076] style = "consistent" # "consistent" (default), "loose", or "tight" allow-loose-continuation = false # allow blank lines around continuation paragraphs ``` | Key | Values | Default | | -------------------------- | ------------------------------------- | --------------- | | `style` | `"consistent"`, `"loose"`, `"tight"` | `"consistent"` | | `allow-loose-continuation` | `true`, `false` | `false` | ### Style values | Value | Description | | -------------- | ----------------------------------------------------------------------- | | `"consistent"` | Lists with blank-separated blocks inside an item stay loose; otherwise majority wins, with ties preferring tight | | `"loose"` | Every inter-item gap must contain a blank line | | `"tight"` | No inter-item gap may contain a blank line | With the default `consistent` style, a list item containing blocks separated by a blank line makes the list loose. MD076 preserves existing separators and adds missing separators, even when most inter-item gaps have no blank line: ```markdown - First item. Another paragraph in the first item. - Second item. - Third item. ``` The same applies to blank-separated code blocks, blockquotes, and nested lists inside an item. Blank lines internal to a nested block do not affect the parent list. A separator that must remain around structural content, such as a fenced code block, also keeps the list loose. Set `style = "tight"` or `allow-loose-continuation = true` to retain the explicit inter-item spacing policy instead. ### allow-loose-continuation When `allow-loose-continuation` is `true`, blank lines around continuation paragraphs within a list item are permitted even in tight mode. This lets you keep tight inter-item spacing while using blank lines to visually separate multi-paragraph content within items. #### Example: tight items with loose continuation ```toml [MD076] style = "tight" allow-loose-continuation = true ``` ```markdown - List item. Continuation paragraph that provides more detail. - Another item. Its continuation paragraph. - Simple item. - Another simple item. ``` Without `allow-loose-continuation`, this would trigger warnings because the blank lines before/after continuation paragraphs look like loose inter-item gaps. With it enabled, only blank lines between actual item markers are checked. ## Automatic fixes This rule can automatically fix violations: - **Missing blank lines** (tight gap when loose is required): a blank line is inserted before the next list item. - **Unexpected blank lines** (loose gap when tight is required): the blank line is removed. Fixes preserve blockquote prefixes (e.g., `>` characters) when list items appear inside a blockquote. ### Blank lines that MD031 requires A list item can open a fenced code block on its own marker line: ````markdown - First item. - ```text code ``` ```` [MD031](md031.md) requires the blank line before that item, so the `tight` style leaves it in place instead of removing it and the two rules do not undo each other. This applies to genuine fenced blocks only. Enough spaces after the marker push the fence to an indent of four, which makes it an indented code block that MD031 says nothing about, so the blank line before it is an ordinary inter-item gap and `tight` removes it. ## Nested lists Nested lists are analysed independently from their parent list. A tight parent with a loose nested list (or vice versa) triggers no warning on the parent level; only the spacing between a list's own items is checked. The nested lists under different parent items are different lists, each judged on its own: ```markdown - Parent one - Tight child - Tight child - Parent two - Loose child - Loose child ``` Nothing is reported here: the parent list is tight, the first nested list is tight, and the second nested list is loose, each consistently. ## Related rules - [MD004 - Use a consistent unordered list marker style](md004.md) - [MD029 - Use a consistent ordered list prefix](md029.md) - [MD030 - Use consistent spacing after list markers](md030.md) - [MD032 - Add blank lines around lists](md032.md)