.pdf

Term side of the Card.
Topic: Document & Data Formats
Unit title: .pdf
Categories: Format
Explanation side of the Card

Explanation: 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.

Example

Wronghtml
<a href="/files/report.pdf">
  Click here
</a>
Righthtml
<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.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy