# .pdf

> The `.pdf` (Portable Document Format) is a widely used file format for documents that preserves formatting across different devices and platforms.

## How do I link to or embed a PDF on a web page accessibly?

The versatile file format used to present documents in a fixed layout, ensuring that they look the same on any device or platform. It supports text, images and hyperlinks and is commonly used for sharing documents.

- Topic: Document & Data Formats
- Type: format

## Example

Wrong:

```html
<a href="/files/report.pdf">
  Click here
</a>
```

Right:

```html
<a href="/files/report.pdf" download>
  Download the annual report (PDF, 2 MB)
</a>
```

The link text tells users what the file is and how big it is before they open it.

## Common mistakes

- Links named "Click here" that open a PDF without warning.
- Publishing scanned PDFs with no text layer, so screen readers and search see nothing.

## Key points

- Links to PDFs say the file type and size in the link text.
- Important content is also available as an HTML page, not only inside a PDF.
- Generated PDFs are tagged, with a title, language and reading order for screen readers.
- Embedded PDFs in `<iframe>` or `<object>` have a title and a download link as fallback.

## Interview questions

### How do I embed a PDF in HTML?

Use `<iframe src="file.pdf" title="...">` or `<object>`, and always include a download link because mobile browsers often do not render PDFs inline.

### Are PDFs bad for accessibility?

Not by default, but many PDFs lack tags, headings and text. HTML is usually easier to make accessible.

### Can search engines index PDF files?

Yes, search engines index text in PDFs, but scanned image-only PDFs need OCR to be searchable.

## Related cards

- [`<a>`](https://wonderium.dev/html/a.md)
- [`<iframe>`](https://wonderium.dev/html/iframe.md)
- [`<object>`](https://wonderium.dev/html/object.md)
- [WCAG](https://wonderium.dev/a11y/wcag.md)
- [.txt](https://wonderium.dev/engineering/txt.md)

---

- Level: [Engineering](https://wonderium.dev/engineering.md)
- HTML version: https://wonderium.dev/engineering/pdf
- Last updated: 2026-11-25
