472,986 Members | 2,999 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 software developers and data experts.

a colored square

Hi,
I was trying to display a small colored square using <table> tag. It
worked fine on the screen but when I do print preview, the square shows
up as white. I used both:
<table width="15" height="15" style="border: 1px solid #000;
background:#00cc00">
....
</tabel>

and

<table width="15" height="15" style="border: 1px solid #000">
<tr><td bgcolor="00cc00"></td></tr>
</table>

but none works.
Can someone tell me why this does not get printed? Is there a CSS
method to create this that would print?

TIA.

Feb 18 '06 #1
7 41310
as*******@hotmail.com wrote:
I was trying to display a small colored square using <table> tag.
Eugh. http://allmyfaqs.net/faq.pl?Tableless_layouts
Can someone tell me why this does not get printed?


Most browsers have an option "Print background colours and images" that is
turned off by default. This is an ink saving measure.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Feb 18 '06 #2
as*******@hotmail.com wrote:
I was trying to display a small colored square using <table> tag.
Why? The most obvious method is to use an image. This approach would let
you specify a textual alternative, and you should actually _start_ from
that. First think what the element is supposed to say. If it is mere
decoration, use alt="". But probably you are not using it for mere
decoration, since you are worrying about what happens when the page is
printed. Try explaining the purpose and context, preferably with a URL.

To create a colored square _using CSS_, you could use e.g.

<div style="width: 15px; height: 15px; background: #0c0;">&nbsp;</div>

but it would be better to use a class attribute and a <style> element or
external style sheet where you make the corresponding settings as well
as display: none for @media print, because normally such an element
should be completely ignored in printing. If it needs to be printed, it
should be content (an image).
It
worked fine on the screen but when I do print preview, the square shows
up as white.
That's because browsers generally don't print backgrounds. No, you
cannot force them. Or even suggest, in CSS.
I used both:
<table width="15" height="15" style="border: 1px solid #000;
background:#00cc00">
...
</tabel>
That's poor practice, since you are using a nonstandard and unreliable
height="..." attribute in a <table> tag, when you could have used it in
a <td> tag. But I digress; that's HTML authoring.
<table width="15" height="15" style="border: 1px solid #000">
<tr><td bgcolor="00cc00"></td></tr>
</table>
There's no relevant difference, of course.
Can someone tell me why this does not get printed?
Your browser is configured not to print backgrounds. So are most other
people's browsers. Besides, even if configured to print backgrounds,
most browsers are incapable of printing green background on a so-called
black and white printer, and people increasingly use good black and
white laser printers instead of color printers that are poor in printing
texts well.
Is there a CSS
method to create this that would print?


As mentioned, an image would do it without any CSS, naturally assuming
that a color printer is used. But if it is mere decoration, a CSS method
is _better_ just _because_ it will cause the colored square to be
suppressed. We don't want to waste the user's ink, do we?
Feb 18 '06 #3
as*******@hotmail.com wrote:
Hi,
I was trying to display a small colored square using <table> tag. It
worked fine on the screen but when I do print preview, the square shows
up as white. I used both:
[snip]

but none works.
Can someone tell me why this does not get printed? Is there a CSS
method to create this that would print?


If you really need a colored image, why not just make a small image
(perhaps even 1 x 1 pixel) and scale it (perhaps adding a border with
CSS if needed)? I'm not sure why you need or want a <table>.

I played around once with making colored square with CSS, and you can
see two examples here:

<http://theodorakis.net/cssart.html>

but I would admit it's really only a "trick."

Nick

--
Nick Theodorakis
ni**************@hotmail.com
contact form:
http://theodorakis.net/contact.html
Feb 18 '06 #4
Sat, 18 Feb 2006 14:53:28 GMT from Nick Theodorakis
<ni**************@hotmail.com>:
I played around once with making colored square with CSS, and you can
see two examples here:

<http://theodorakis.net/cssart.html>

but I would admit it's really only a "trick."


Most impressive! Sometimes things like this are worth doing just for
the sheer fun of stretching the boundaries, even though they might
not be appropriate for production use.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you
Feb 18 '06 #5

Stan Brown wrote:
Sat, 18 Feb 2006 14:53:28 GMT from Nick Theodorakis
<ni**************@hotmail.com>:
I played around once with making colored square with CSS, and you can
see two examples here:

<http://theodorakis.net/cssart.html>

but I would admit it's really only a "trick."


Most impressive! Sometimes things like this are worth doing just for
the sheer fun of stretching the boundaries, even though they might
not be appropriate for production use.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you


Thank you all for your input.
The reason I needed to display these colored squares is that I have a
form that allows the user to configure some properties of an item. One
of the properties is the color scheme. So, if they selected green and
red (they have a choice of 64 colors), at the end I wanted to present
them with a summary of their configuration and wanted to show their
selected colors as small colored squares. Therefore, I don't know
beforehand what he color is going to be (I am using php to create the
resulting summary page) and it wouldn't make sense to say that one of
the colors they chose was 00CCFF.
I will get rid of the tble and use your CSS suggestions. I am begining
to learn CSS and would love to design the site in a way I could get rid
of all the <table> and spacer.gif tags.

Feb 18 '06 #6
as*******@hotmail.com wrote:

(they have a choice of 64 colors), at the end I wanted to present
them with a summary of their configuration and wanted to show their
selected colors as small colored squares. Therefore, I don't know
beforehand what he color is going to be (I am using php


If you're using php to generate this, then you can create an image on
the fly and color it with whatever choice they made. ImageMagick or GD
libraries should do it. Ask in a php forum for more info.

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Feb 18 '06 #7
On Sat, 18 Feb 2006 14:53:28 GMT, Nick Theodorakis
<ni**************@hotmail.com> wrote:

: > I was trying to display a small colored square using <table> tag. It
: > worked fine on the screen but when I do print preview, the square shows
: > up as white.
That's because it actually is a _background_ color.

Sid

Feb 18 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: pamelafluente | last post by:
Hi I have some instances of a class: Class Myobject Public Color As Color Public Label As String End Class I need to show these instances on a treeview (which has checked boxes)
0
by: lazaridis_com | last post by:
Colored Code Blocks Pudge generated documentation can contain colored code blocks, using the rst directive "..code-block:: Python" (an other languages supported by SilverCity). ...
1
by: magic man | last post by:
I am 50 years old ...and am working physical models of the math structure called a magic square .. for my own interest. My present problem is this. I have a topograhical model for the square...
7
by: Rohan | last post by:
Hello, Can some one tell me how do I get colored text. Say when I want to write something in a text file , how do I get it colored.
2
lotus18
by: lotus18 | last post by:
Hello World Can anyone explain to me why i'm having a blue colored text in some of my files. My Local Disk (D:) also got it. I think I got this problem when I share my Local Disk (D:) over the...
6
by: CodeTilYaDrop | last post by:
I was wondering how some people have colored code and others do not. How do I get the colored code to show up in the forum? I think you can read it better. I was just curious so I can do it in the...
5
by: WanHongbin | last post by:
#include <stdio.h> double square(); /*without declare main() { double s; s = square(2); printf("%g\n", s); }
6
by: Blue sky | last post by:
Hi ,I think the follow program is right in logical But why the compiler output :"square:declared identifier" #include<stdio.h> #include<math.h> int main() { double x1;
2
by: khacthuy | last post by:
I need to write a program with content: Colored plane graphs. Tell people what I know. I always code for the study. Thanks please send me mail: khacthuy.3k@gmail.com I come from VietNamese...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.