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

inline style with @media=print

P: n/a
Hi

I'm trying to hide from printing a specific element of a page but I don't
know how (and if) I could. Here is an example of what I'm trying to do:

[The text here must be visible in print mode]
<h1>Hidden in print mode</h1>
<p>Also hidden in print mode</p>
[Following text visible too]

Is there a way to hide these two paragraphs with an inline style?
(I don't know if "inline" is the correct word, so what I'm trying to say is
something like: <h1 style="@media=print(display:none)">)

Thanks

____________________
Merlin dying, to the Lady of the Lake:
"we lived our lives with passion and devotion"

-=- geotso -=-
(remove the TRAP to contact me)
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
"geotso" <ge********@hotmail.com> wrote in message
news:bs**********@usenet.otenet.gr...
Hi

I'm trying to hide from printing a specific element of a page but I don't
know how (and if) I could. Here is an example of what I'm trying to do:

[The text here must be visible in print mode]
<h1>Hidden in print mode</h1>
<p>Also hidden in print mode</p>
[Following text visible too]

Is there a way to hide these two paragraphs with an inline style?
(I don't know if "inline" is the correct word, so what I'm trying to say is something like: <h1 style="@media=print(display:none)">)


Why would you want to use inline styles? They're evil. :) Seriously,
though, it defeats the purpose of seperating presentation from content. You
can do it if you don't use inline styles, but I don't know how you'd do it
with inline styles.

Regards,
Peter Foti
Jul 20 '05 #2

P: n/a

"geotso" <ge********@hotmail.com> wrote in message
news:bs**********@usenet.otenet.gr...
Is there a way to hide these two paragraphs with an inline style?


In the latest XHTML definition (1.1? off the top of my head) the style
attribute is deprecated in all tags. So it's not a bad idea to stop using
any inline styles. Add a class and define it either in the external CSS or
between the <style> tags in your header.
Jul 20 '05 #3

P: n/a
Neal wrote:
In the latest XHTML definition (1.1? off the top of my head) the style
attribute is deprecated in all tags.


Not in 1.1 it isn't.

--
Spartanicus
Jul 20 '05 #4

P: n/a

"Spartanicus" <me@privacy.net> wrote in message
news:8c********************************@news.spart anicus.utvinternet.ie...
Neal wrote:
In the latest XHTML definition (1.1? off the top of my head) the style
attribute is deprecated in all tags.


Not in 1.1 it isn't.

--
Spartanicus


http://www.w3.org/TR/xhtml11/doctype.html

Unless I'm screwed up... which IS possible...
Jul 20 '05 #5

P: n/a
Neal wrote:
>In the latest XHTML definition (1.1? off the top of my head) the style
>attribute is deprecated in all tags.


Not in 1.1 it isn't.


http://www.w3.org/TR/xhtml11/doctype.html

Unless I'm screwed up... which IS possible...


I'm not sure what that refers to, usage of the style attribute is valid
in xhtml 1.1, given that there is no transitional doctype with 1.1,
afaik that implies that it isn't deprecated

--
Spartanicus
Jul 20 '05 #6

P: n/a
Spartanicus wrote:
Neal wrote:

In the latest XHTML definition (1.1? off the top of my head) the style
attribute is deprecated in all tags.

Not in 1.1 it isn't.


http://www.w3.org/TR/xhtml11/doctype.html

Unless I'm screwed up... which IS possible...

I'm not sure what that refers to, usage of the style attribute is valid
in xhtml 1.1, given that there is no transitional doctype with 1.1,
afaik that implies that it isn't deprecated


Indeed, it isn't even deprecated in XHTML2.0 (whenever that comes out),
though the fact that it is still valid, doesn't mean you should use it.

--
Anne van Kesteren
<http://www.annevankesteren.nl/>
Jul 20 '05 #7

P: n/a
"geotso" <ge********@hotmail.com> wrote in message
news:bs**********@usenet.otenet.gr...
Hi

I'm trying to hide from printing a specific element of a page but I don't
know how (and if) I could. Here is an example of what I'm trying to do:

[The text here must be visible in print mode]
<h1>Hidden in print mode</h1>
<p>Also hidden in print mode</p>
[Following text visible too]

@media print{
{
h1:display:none;
}
{p:display:none;
}
}

This will hide every h1 and p element from printing. If you need to only
hide one specific h1 element and one specific p element, then you will have
to give them a class (to differentiate them from other h1 and p tags on the
page) and then adjust the css in your @media:print rule accordingly.

Have a look at www.webmasterworld.com/forum83 where this had been discussed
in the last month or so.
Jools
Jul 20 '05 #8

P: n/a
In article news individual wrote:
"geotso" <ge********@hotmail.com> wrote in message
news:bs**********@usenet.otenet.gr...
Hi

I'm trying to hide from printing a specific element of a page but I don't
know how (and if) I could. Here is an example of what I'm trying to do:

[The text here must be visible in print mode]
<h1>Hidden in print mode</h1>
<p>Also hidden in print mode</p>
[Following text visible too]
@media print{
{
h1:display:none;
}
{p:display:none;
}
}

This will hide every h1 and p element from printing.


Well, if it does, that means that you have incorrectly working browser.

Correct syntax:

@media print {
h1,p {display:none;}
}
If you need to only
hide one specific h1 element and one specific p element, then you will have
to give them a class (to differentiate them from other h1 and p tags on the
page) and then adjust the css in your @media:print rule accordingly.


This is correct.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Saapi lähettää meiliä, jos aihe ei liity ryhmään, tai on yksityinen
tjsp., mutta älä lähetä samaa viestiä meilitse ja ryhmään.

Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.