473,772 Members | 3,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Replacing text with a background image affects printing

I have seen lots of examples where some HTML text is replaced with a
background image using CSS. For example, replacing the text of an <h1> with
a graphical logo, like so:

CSS:
h1 span { display: none; }
h1 { height: 100px; background: url("mycompany. gif") no-repeat 35px 40px; }

HTML:
<h1><span>My Company</span></h1>

This allows the text version to be displayed for non-CSS browsers, and
allows a more visually appealing logo to be displayed for CSS enabled
browsers (assuming they don't have images turned off). One side effect of
this is that when the user prints, the default settings (at least with IE
6... I assume other browsers are probably similar) do not print background
images. So instead of seeing the graphical logo or the text, there is just
empty space.

Is there a good way around this? At the very least, I can get the text
version to print by adding the following CSS:
@media print
{
h1 span { display: inline; }
}

However, if the user configures his/her browser to print background images,
then BOTH the background image and the text are printed. Is there a
solution, or am I better off just putting the image in the <h1> (using the
<img> element instead of using CSS to add it as a background)?

Thanks,
Peter Foti
Jul 20 '05 #1
6 3627
Peter Foti wrote:
I have seen lots of examples where some HTML text is replaced with
a background image using CSS. For example, replacing the text of
an <h1> with a graphical logo, like so:

CSS: h1 span { display: none; } h1 { height: 100px; background:
url("mycompany. gif") no-repeat 35px 40px; }

HTML: <h1><span>My Company</span></h1>

This allows the text version to be displayed for non-CSS browsers,
and allows a more visually appealing logo to be displayed for CSS
enabled browsers (assuming they don't have images turned off).
It is, of course, dangerous to make assumptions on the www.

(Caveat: I have used this technique, only once, and implemented it
carefully. Moreover, I consider the circumstances different from
most. I won't bore you with the details.)
am I better off just putting the image in
the <h1> (using the <img> element instead of using CSS to add it as
a background)?


I think you're better off using an img element inside h1.

--
Brian
follow the directions in my address to email me

Jul 20 '05 #2
Peter Foti wrote:
I have seen lots of examples where some HTML text is replaced with a
background image using CSS. For example, replacing the text of an
<h1> with a graphical logo, like so:

CSS:
h1 span { display: none; }
h1 { height: 100px; background: url("mycompany. gif") no-repeat 35px
40px; }

HTML:
<h1><span>My Company</span></h1>

This allows the text version to be displayed for non-CSS browsers, and
allows a more visually appealing logo to be displayed for CSS enabled
browsers (assuming they don't have images turned off).


Why not simply use the logo-image inside the h1 with alt-text "My
Company"? Works with or without CSS, with or without images.

--
Google Blogoscoped
http://blog.outer-court.com
Jul 20 '05 #3
Peter Foti wrote:
I have seen lots of examples where some HTML text is replaced with a
background image using CSS. For example, replacing the text of an <h1> with
a graphical logo, like so:

CSS:
h1 span { display: none; }
h1 { height: 100px; background: url("mycompany. gif") no-repeat 35px 40px; }

HTML:
<h1><span>My Company</span></h1>

This allows the text version to be displayed for non-CSS browsers, and
allows a more visually appealing logo to be displayed for CSS enabled
browsers (assuming they don't have images turned off).


This particular method is a bad idea. Most modern screen readers will
apply the display:none property and end up with no h1 content at all.
See <URL:http://css-discuss.incutio .com/?page=Screenrea derVisibility>

--
To email a reply, remove (dash)un(dash). Mail sent to the un
address is considered spam and automatically deleted.
Jul 20 '05 #4
On 19 Nov 2003 16:42:33 GMT, "Philipp Lenssen" <in**@outer-court.com>
wrote:
Peter Foti wrote:
I have seen lots of examples where some HTML text is replaced with a
background image using CSS. For example, replacing the text of an
<h1> with a graphical logo, like so:

CSS:
h1 span { display: none; }
h1 { height: 100px; background: url("mycompany. gif") no-repeat 35px
40px; }

HTML:
<h1><span>My Company</span></h1>

This allows the text version to be displayed for non-CSS browsers, and
allows a more visually appealing logo to be displayed for CSS enabled
browsers (assuming they don't have images turned off).


Why not simply use the logo-image inside the h1 with alt-text "My
Company"? Works with or without CSS, with or without images.


Agreed. Background images should be used for decoration only. Anything
containing information should be in the foreground.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 20 '05 #5
On Wed, 19 Nov 2003 11:13:19 -0600, kchayka <kc*********@si hope.com> wrote:
Peter Foti wrote:
I have seen lots of examples where some HTML text is replaced with a
background image using CSS. For example, replacing the text of an <h1>
with a graphical logo, like so:

CSS:
h1 span { display: none; }
h1 { height: 100px; background: url("mycompany. gif") no-repeat 35px
40px; }

HTML:
<h1><span>My Company</span></h1>

This allows the text version to be displayed for non-CSS browsers, and
allows a more visually appealing logo to be displayed for CSS enabled
browsers (assuming they don't have images turned off).


This particular method is a bad idea. Most modern screen readers will
apply the display:none property and end up with no h1 content at all.
See <URL:http://css-discuss.incutio .com/?page=Screenrea derVisibility>


At least for the printed version, the solution could be:

@media print {
h1 spam {display:inline ;}
h1 {background: none;}
}

But in general, I don't like idea. Not just for screenreaders; a simple
copy & paste also misses the hidden text. But if you really need a super
duper flashy website, it is a nice idea. I'll just go into User mode in my
browser when I actually need to work with the text...

--
Rijk van Geijtenbeek

The Web is a procrastination apparatus:
It can absorb as much time as is required to ensure that you
won't get any real work done. - J.Nielsen
Jul 20 '05 #6
Thanks to all that posted. I will follow the advice and keep image logo's
in the content instead of making them presentational.

Regards,
Peter Foti
Jul 20 '05 #7

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

Similar topics

2
4380
by: Moon | last post by:
Seems I still haven't got the hang of all those window generating code in Javascript. I've got a page with about 15 photo thumbnails. When you click on a thumbnail a new window pops up which shows the enlarged version of said thumbnail. This works fine on all current browsers I've tested. However, in case I do not close the popup but click on another thumbnail instead, only IE replaces the enlarged pic by the new one, Firebird and Opera...
24
8065
by: Markus Ernst | last post by:
Hi I have a title with a title gif: <h1><img src="mytitle.gif" alt="This is my title"></h1> So this is text-based browser and search-engine friendly and can be easily formatted with a style sheet. Now I have a separate stylesheet for media="print". As the title gif does
1
2185
by: Andrew Poulos | last post by:
Say I have a page, which has been created by a third party, and the page may contain some pre-specified text. How can I find and replace that text dynamically? For example, if the page I have contains this HTML: <div id=”oDiv” style="margin-bottom:10px;">{when}</div> <div> <table style="border:1px solid gray"> <tr> <td>blah</td>
16
3939
by: J. B. Moreno | last post by:
I read the faq, and it mentions that IE 4 on windows requires setting a printing option to allow background colors to be printed. Things change, life goes on, other browsers come into existence.... So, is there a way in CSS to say "Yeah, print these background colors", without the user having to turn on an option that will then apply to all pages printed? Thanks,
4
2136
by: CG3000 | last post by:
I create a .PNG image ( in Macromedia Fireworks ) which has an gif in it in the top left corner and a lot of empty canvas space to the right. I use about 10 text boxes on a form to populate that empty space with text. I then print the image ( from a picture box on my form) on a UPS Thermal Printer ( label printer)
12
22362
by: mi0sis | last post by:
Right now I am currently using this: ------------------------------------------------------------ .div0 { background-image:url(http://www.rubnip.com/Pictures/topback.gif); background-position:center center; background-repeat:no-repeat; background-attachent:fixed; background-color:black; color:FFFFFF; border:0px solid; border-color:grey;
2
11744
by: yogarajan | last post by:
hi i have create one html file. That file contains background image . but print preview time not display . i am go to tools -> internet options-> advanced options -> printing -> print background colors and images - checkbox enabled that time only appear background image my client donot that step i want default background image with print out my code start here
1
1457
by: Star258 | last post by:
I have a few paragraphs on my site and an ul that I’ve set up with a css background image. I wanted the image separate from the main background and still have the ability to type on it. Is there a way to get the text to wrap around the ul and the image? Or a better way to set it up in the first place? Right now I can only see how to have text above it and text below it. Any help would be great Thanks <!DOCTYPE html PUBLIC...
1
4222
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being aligned to the top, along with the slideshow and link buttons, you have to scroll down to see the text - how can I make IE6 display correctly? http://geekarama.co.uk/new_home.html here is the code for new_home.html and following that the CSS...
0
9620
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10104
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7460
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6715
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.