# CSS Print styles with dynamic content

**URL:** <https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861>\
**Category:** web dev\
**Created:** [June 19, 2008, 8:45pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861 "2008-06-19T20:45:53Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![NS05](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ns05/32/2205_2.png) [@NS05](https://forum.kirupa.com/u/NS05)\
**Post date:** [June 19, 2008, 8:45pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861/1 "2008-06-19T20:45:53Z")

</div>

Hi,I have a site that is using PHP. I have already created a Print.css document that has different styles for printing the pages. I have run into a problem when I have buttons or images that are being pulled in dynamically using PHP that I dont want visible when the user prints. I have buttons I also dont want to be displayed that are dynamiclally pulled into the page. I want BackBTN\_R.gif to not be displayed when they go to print. How can I write the CSS to do this? Thanks!

---

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [June 19, 2008, 8:56pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861/2 "2008-06-19T20:56:38Z")

</div>

if you are using PHP to output your content, then output the content you want hidden with a class attached to it

because, BackBTN\_R.gif has to be attached to some HTML element to be displayed, so just make PHP output this:

\<img src=“images/BackBTN\_R.gif” class=“hide\_print”/\>

and then in your CSS you just do

.hide\_print { display: none; }

you could also apply this class to every element on the page you want hidden instead of referencing them specifically by ID, the way you are doing now.

Which would effectively make your print.css one definition

---

<div class="post-metadata">

**Author:** ![NS05](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ns05/32/2205_2.png) [@NS05](https://forum.kirupa.com/u/NS05)\
**Post date:** [June 19, 2008, 9:10pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861/3 "2008-06-19T21:10:22Z")

</div>

If I add that in it makes my whole page not work.

"

---

<div class="post-metadata">

**Author:** ![redelite](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@redelite](https://forum.kirupa.com/u/redelite)\
**Post date:** [June 19, 2008, 9:17pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861/4 "2008-06-19T21:17:15Z")

</div>

wrong place, you put it in the javascript…

you need to put the **_class="hide\_print"_** on the **_\<img /\>_** tag so that after your php finishes spitting out all your code, your HTML for that image should read:

```auto

<img src="images/BackBTN_R.gif" class="hide_print" />

```

---

<div class="post-metadata">

**Author:** ![NS05](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ns05/32/2205_2.png) [@NS05](https://forum.kirupa.com/u/NS05)\
**Post date:** [June 19, 2008, 9:20pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861/5 "2008-06-19T21:20:41Z")

</div>

perfect, thank you so much!!!

---

<div class="post-metadata">

**Author:** ![redelite](https://avatars.discourse-cdn.com/v4/letter/r/dc4da7/32.png) [@redelite](https://forum.kirupa.com/u/redelite)\
**Post date:** [June 19, 2008, 9:21pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861/6 "2008-06-19T21:21:49Z")

</div>

no prob… :thumb2:

---

<div class="post-metadata">

**Author:** ![fasterthanlight](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fasterthanlight](https://forum.kirupa.com/u/fasterthanlight)\
**Post date:** [June 19, 2008, 10:08pm UTC](https://forum.kirupa.com/t/css-print-styles-with-dynamic-content/263861/7 "2008-06-19T22:08:00Z")

</div>

Yay TeamWork!!! :fab:
