473,405 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 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 41370
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.