By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,866 Members | 2,039 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,866 IT Pros & Developers. It's quick & easy.

Hide input buttons when printing

P: n/a
Hello,

I am creating a stylesheet for printing out some webpages. I would
like the printed pages to NOT display buttons. However, text fields
should be printed. Therefore, the following code will not work:

input { display : none; }

....since text fields will also be hidden. I am looking for a solution
along the lines of:

input:button { display : none; }

Is anything like this possible? Thanks.
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


Trent wrote:

I am creating a stylesheet for printing out some webpages. I would
like the printed pages to NOT display buttons. However, text fields
should be printed. Therefore, the following code will not work:

input { display : none; }

...since text fields will also be hidden. I am looking for a solution
along the lines of:

input:button { display : none; }


input[type=button] {
display: none;
}
will hide
<input type="button">
elements with browsers supporting that CSS 2 selector (Mozilla, Netscape
6/7, Opera). See
http://www.w3.org/TR/CSS2/selector.h...bute-selectors

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2

P: n/a
sp*******@marx7.org (Trent) wrote in
news:22************************@posting.google.com :
I am creating a stylesheet for printing out some webpages. I would
like the printed pages to NOT display buttons. However, text fields
should be printed. Therefore, the following code will not work:

input { display : none; }

...since text fields will also be hidden. I am looking for a solution
along the lines of:

input:button { display : none; }

Is anything like this possible? Thanks.


In principle you could use attribute selectors:

input[type="button"] {display: none;}

but unfortunately IE doesn't support them. I suggest you give any input
elements that shouldn't be printed a class of "noprint" or the like and
then use that in your stylesheet. More effort, but should work nearly
everywhere.
Jul 20 '05 #3

P: n/a

"Trent" <sp*******@marx7.org> wrote in message
news:22************************@posting.google.com ...
Hello,

I am creating a stylesheet for printing out some webpages. I would like the printed pages to NOT display buttons. However, text fields should be printed. Therefore, the following code will not work:
input { display : none; }

...since text fields will also be hidden. I am looking for a solution along the lines of:

input:button { display : none; }

Is anything like this possible? Thanks.


I had a similar issue getting a button to have a top margin of 1
em while no other inputs were affected. I did this.

input.button {
margin-top: 1em
}
.. . .
<input class="button" ...
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.