Discussion: To hide a tag
Afficher un message
Vieux 08/03/2008, 14h36   #3
Jukka K. Korpela
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: To hide a tag

Scripsit Andy Dingley:

> Use the classes "print-only" and "no-print" in your HTML and place
> this CSS in a stylesheet


For a starter, valid markup should be used. The OP's code snippet was
uninformative except for revealing that the markup was grossly invalid.

> .print-only{
> display: none;
> visibility: hidden;
> }


Why set visibility when display: none? To hide something that does not
exist (in rendering)?

And since the request was to hide a "tag" (i.e., element) during display
on screen and to show when the page is printed, one class and and rule
should be enough. For example, class="print-only" for elements that
should appear in print only, with the CSS rule

@media screen { .print-only { display: none; } }

Problem solved? This does means that in rendering modes other than
screen or print, the content would appear, but nothing was said about
such modes in the original posting, and they need to be separately
considered anyway, if relevant.

> /* Simple standards-based way to turn printing on */
> .print-only {
> display: inherit;
> visibility: visible;
> }


Pardon? Apart from being much too complex, this fails to work in many
occasions. There will be great confusion if you make an element inherit
its display value from its parent.

> /* IE hack, because it doesn't support display: inherit; */
> *.print-only {
> display: block;
> }


Getting deeper into trouble, are we not?

> tr.print-only { display: table-row; }


What's the idea of using an "IE hack" that deploys constructs that are
not supported at all by IE?

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

  Réponse avec citation
 
Page generated in 1,35141 seconds with 9 queries