---
title: MD002 - First Heading Should Be Top Level
description: Ensures the first heading in a document is a top-level heading (h1)
---

# MD002 - First Heading Should Be Top Level

**Rule Type**: `warning`

**Default Level**: `1` (h1)

## Description

This rule ensures that the first heading in a document is a top-level heading (h1). Using a top-level heading  
as the first heading helps establish the document's main topic and maintains proper document structure.

## Configuration

This rule has the following configuration options:

- `level`: The level that the first heading should be (default: 1)

Example configuration:

```json
{
  "MD002": {
    "level": 1
  }
}
```

## Examples

<!-- markdownlint-disable -->
### Valid

```markdown
# Document Title

## Section 1

### Subsection 1.1

## Section 2
```

### Invalid

```markdown
## Document Title

### Section 1

# Main Heading
```

### Fixed

```markdown
# Document Title

## Section 1

### Subsection 1.1
```

### Special Cases

```markdown
### Third Level Heading

Heading
-------
```

```markdown
## Second Level Heading

Heading
=======
```
<!-- markdownlint-enable -->

## Rationale

Starting a document with a top-level heading:

1. Establishes the main topic of the document
2. Creates a proper document outline
3. Improves accessibility for screen readers
4. Maintains consistent document structure

## Related Rules

- [MD001 - Heading Levels](md001.md): Ensures heading levels increment by one level at a time
- [MD003 - Heading Style](md003.md): Enforces consistent heading style
- [MD025 - Single Title/H1](md025.md): Ensures there's only one top-level heading
