Log in Sign up

Applying CSS to PDF embeds?

I'd like to change the width of PDF iframe embeds – would it be possible to add a class to these so I can target them?


2 years ago, 1 replies   developers   Edit question

You can target these PDF embeds with a CSS attribute selector. Let's say you have an embed that looks like this:

<iframe src="/files/example.pdf"></iframe>

You can target this and others like it in CSS like so:

iframe[src$=".pdf"] {
  width: 100px
}
Answered 2 years ago · Edit answer