473,545 Members | 2,051 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:#00c c00">
....
</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 41384
as*******@hotma il.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*******@hotma il.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:#00c c00">
...
</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*******@hotma il.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*******@hotma il.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
3455
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
1574
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). http://pudge.lesscode.org/trac/ticket/21 http://pudge.lesscode.org/trac/changeset/126
1
3901
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 ... where each cell in the square is a solid structure to the height specified by the value in that cell. Then conceptually I pour water on top of the...
7
9153
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
3765
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 network. Usually the colored text must be black, right? BTW, I'm using Win XP Service Pack 2. : ) Rey Sean
6
2170
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 future. - SEOT
5
3122
by: WanHongbin | last post by:
#include <stdio.h> double square(); /*without declare main() { double s; s = square(2); printf("%g\n", s); }
6
4155
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
1892
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 ----------------------------------------------------------------- Algorithm colored graphs Input: graph G = (V, E). Output: graph G = (V, E) is the...
0
7475
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7918
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7766
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5981
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5341
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4958
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1022
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.