473,659 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How best to style images in links?

Eli
I'm fairly unfamiliar with CSS, but want to develop a way to skin a
web application by using stylesheets for everything, including all
images.

I have a set of images used as buttons - mostly for simple links
rather than form input buttons.

<a href="mypage.ph p?action=add&id =7"><img src="..." border="0"></a>
<a href="mypage.ph p?action=delete &id=7"><img src="..." border="0"></a>

What is the way to do this? Define classes for the links or for the
images? Rollovers aren't particularly important, but if easily doable
would be a nice addition to the skinning ability.

Jul 21 '05 #1
14 4822
Els
Eli wrote:
I'm fairly unfamiliar with CSS, but want to develop a way to skin a
web application by using stylesheets for everything, including all
images.

I have a set of images used as buttons - mostly for simple links
rather than form input buttons.

<a href="mypage.ph p?action=add&id =7"><img src="..." border="0"></a>
<a href="mypage.ph p?action=delete &id=7"><img src="..." border="0"></a>

What is the way to do this? Define classes for the links or for the
images? Rollovers aren't particularly important, but if easily doable
would be a nice addition to the skinning ability.


If you want the image to change on hover, you shouldn't set it in the
html, but as a background image throught CSS. You'll have to define
the width and height of the <a> element, and set one background image
for a:link and a:visited, and another for a:focus, a:active and
a:hover. For the 'filling' of the <a> element you could use a &nbsp;,
or a transparent image.

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: The Doors - Light My Fire
Jul 21 '05 #2
Eli
On Sat, 9 Jul 2005 21:29:09 +0200, Els <el*********@ti scali.nl> wrote:
Eli wrote:
I'm fairly unfamiliar with CSS, but want to develop a way to skin a
web application by using stylesheets for everything, including all
images.

I have a set of images used as buttons - mostly for simple links
rather than form input buttons.

<a href="mypage.ph p?action=add&id =7"><img src="..." border="0"></a>
<a href="mypage.ph p?action=delete &id=7"><img src="..." border="0"></a>

What is the way to do this? Define classes for the links or for the
images? Rollovers aren't particularly important, but if easily doable
would be a nice addition to the skinning ability.


If you want the image to change on hover, you shouldn't set it in the
html, but as a background image throught CSS. You'll have to define
the width and height of the <a> element, and set one background image
for a:link and a:visited, and another for a:focus, a:active and
a:hover. For the 'filling' of the <a> element you could use a &nbsp;,
or a transparent image.

<a class="b_add" href="mypage.ph p?action=add&id =7"><img
src="images/transparent.gif " border="0" alt="Add"></a>

a:link.b_add, a:visited.b_add {
background-image: url(images/b_add.gif);
height: 13px;
width: 13px;
}

Works in IE but not Firefox. Also, I get a very brief hourglass icon
in IE when I roll over the link.

Jul 21 '05 #3
Els wrote:
Eli wrote:
I'm fairly unfamiliar with CSS, but want to develop a way to skin a
web application by using stylesheets for everything, including all
images.

I have a set of images used as buttons - mostly for simple links
rather than form input buttons.

<a href="mypage.ph p?action=add&id =7"><img src="..." border="0"></a>
<a href="mypage.ph p?action=delete &id=7"><img src="..." border="0"></a>

What is the way to do this? Define classes for the links or for the
images? Rollovers aren't particularly important, but if easily doable
would be a nice addition to the skinning ability.


If you want the image to change on hover, you shouldn't set it in the
html, but as a background image throught CSS. You'll have to define
the width and height of the <a> element, and set one background image
for a:link and a:visited, and another for a:focus, a:active and
a:hover. For the 'filling' of the <a> element you could use a &nbsp;,
or a transparent image.


Or better, use the appropriate text for the link (the only you use for the
alt attribute of the images - that you omitted in your example to keep the
lines short ;) Then search the web for an 'image replacement' technique to
get rid of the text via CSS.

And even better: don't use links for actions that cause changes on your
server (DB or what ever). That's what POST requests are supposed to do. A
GET request should not change the state on the server. Read e.g.
http://www.cs.tut.fi/~jkorpela/forms/methods.html for more info on this
topic.
--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Jul 21 '05 #4
Els
Eli wrote:
<a class="b_add" href="mypage.ph p?action=add&id =7"><img
src="images/transparent.gif " border="0" alt="Add"></a>

a:link.b_add, a:visited.b_add {
background-image: url(images/b_add.gif);
height: 13px;
width: 13px;
}

Works in IE but not Firefox.
Do you have an online example of it not working? (not that I don't
believe you, but that makes it easier to find out what the reason is)
Also, I get a very brief hourglass icon
in IE when I roll over the link.


I've seen short flashes in IE, but never an hourglass icon. What's the
size in bytes of those images?

--
Els http://locusmeus.com/
Sonhos vem. Sonhos vão. O resto é imperfeito.
- Renato Russo -
Now playing: Dave Edmunds - Girls Talk
Jul 21 '05 #5
Eli
On Sat, 09 Jul 2005 22:09:22 +0200, Benjamin Niemann <pi**@odahoda.d e>
wrote:
Or better, use the appropriate text for the link (the only you use for the
alt attribute of the images - that you omitted in your example to keep the
lines short ;) Then search the web for an 'image replacement' technique to
get rid of the text via CSS.
I don't like the idea of what that looks like if the images fail to
load for whatever reason - the user
And even better: don't use links for actions that cause changes on your
server (DB or what ever). That's what POST requests are supposed to do. A
GET request should not change the state on the server. Read e.g.
http://www.cs.tut.fi/~jkorpela/forms/methods.html for more info on this
topic.


I didn't write the server.

Jul 21 '05 #6
Eli
On Sat, 09 Jul 2005 14:23:25 -0600, Eli <no@one.com> wrote:
On Sat, 09 Jul 2005 22:09:22 +0200, Benjamin Niemann <pi**@odahoda.d e>
wrote:
Or better, use the appropriate text for the link (the only you use for the
alt attribute of the images - that you omitted in your example to keep the
lines short ;) Then search the web for an 'image replacement' technique to
get rid of the text via CSS.


I don't like the idea of what that looks like if the images fail to
load for whatever reason - the user
And even better: don't use links for actions that cause changes on your
server (DB or what ever). That's what POST requests are supposed to do. A
GET request should not change the state on the server. Read e.g.
http://www.cs.tut.fi/~jkorpela/forms/methods.html for more info on this
topic.


I didn't write the server.


Sorry about that - sent inadvertently. Actually, I'm now playing with
the FIR technique and although it may work, I'm not sure I see the
importance of setting the links down as text and then doing an image
replacement of that text. From what I read, in many cases the text
won't be displayed even if the image fails to load.

Two things that are affecting layout: The page is rendered as if the
text were still there (which probably makes sense). If I have a text
link "Add to list" that is approximatelyy 75px by 13px, then replace
it with a 13x13 icon, the page is still rendered with a 75x13 link - I
even get a large blank area next to the icon that functions as a link.

And oddly enough, I get the same brief hourglass in IE that the other
mentioned technique sees.

Jul 21 '05 #7

"Eli" <no@one.com> wrote in message
news:1v******** *************** *********@4ax.c om...
On Sat, 09 Jul 2005 14:23:25 -0600, Eli <no@one.com> wrote:
On Sat, 09 Jul 2005 22:09:22 +0200, Benjamin Niemann <pi**@odahoda.d e>
wrote:
Or better, use the appropriate text for the link (the only you use for
the
alt attribute of the images - that you omitted in your example to keep
the
lines short ;) Then search the web for an 'image replacement' technique
to
get rid of the text via CSS.


I don't like the idea of what that looks like if the images fail to
load for whatever reason - the user
And even better: don't use links for actions that cause changes on your
server (DB or what ever). That's what POST requests are supposed to do. A
GET request should not change the state on the server. Read e.g.
http://www.cs.tut.fi/~jkorpela/forms/methods.html for more info on this
topic.


I didn't write the server.


Sorry about that - sent inadvertently. Actually, I'm now playing with
the FIR technique and although it may work, I'm not sure I see the
importance of setting the links down as text and then doing an image
replacement of that text. From what I read, in many cases the text
won't be displayed even if the image fails to load.

Two things that are affecting layout: The page is rendered as if the
text were still there (which probably makes sense). If I have a text
link "Add to list" that is approximatelyy 75px by 13px, then replace
it with a 13x13 icon, the page is still rendered with a 75x13 link - I
even get a large blank area next to the icon that functions as a link.

And oddly enough, I get the same brief hourglass in IE that the other
mentioned technique sees.


Rather than 2 images, have 1 image and then just change the offset on the
hover.
Jul 21 '05 #8
Eli wrote:
On Sat, 09 Jul 2005 22:09:22 +0200, Benjamin Niemann <pi**@odahoda.d e>
wrote:

[snip]
And even better: don't use links for actions that cause changes on your
server (DB or what ever). That's what POST requests are supposed to do. A
GET request should not change the state on the server. Read e.g.
http://www.cs.tut.fi/~jkorpela/forms/methods.html for more info on this
topic.


I didn't write the server.


Then you should remember the name/address of the author in order to redirect
complains of angry users to him/her, if someone e.g. runs a link checker on
the page or (if it is publicly accessible) a web spider comes around and
all 'delete' links are 'clicked'.

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Jul 21 '05 #9
Eli wrote:
On Sat, 09 Jul 2005 14:23:25 -0600, Eli <no@one.com> wrote:
On Sat, 09 Jul 2005 22:09:22 +0200, Benjamin Niemann <pi**@odahoda.d e>
wrote:
Or better, use the appropriate text for the link (the only you use for
the alt attribute of the images - that you omitted in your example to
keep the lines short ;) Then search the web for an 'image replacement'
technique to get rid of the text via CSS.


I don't like the idea of what that looks like if the images fail to
load for whatever reason - the user


Sorry about that - sent inadvertently. Actually, I'm now playing with
the FIR technique and although it may work, I'm not sure I see the
importance of setting the links down as text and then doing an image
replacement of that text. From what I read, in many cases the text
won't be displayed even if the image fails to load.

Two things that are affecting layout: The page is rendered as if the
text were still there (which probably makes sense). If I have a text
link "Add to list" that is approximatelyy 75px by 13px, then replace
it with a 13x13 icon, the page is still rendered with a 75x13 link - I
even get a large blank area next to the icon that functions as a link.


This should not happen, if you properly define the width & height of the
link.

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://www.odahoda.de/
Jul 21 '05 #10

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

Similar topics

13
2616
by: Monty | last post by:
I've been searching for guidance on which of the approaches used for skipping repetive links (e.g., link as normal text, link as alt text on invisible image, link with same forground and background colors that becomes visible when in hover or active state using css) is the best approach. Is there any place on the net where this is addressed? Thanks in advance.
131
21634
by: Peter Foti | last post by:
Simple question... which is better to use for defining font sizes and why? px and em seem to be the leading candidates. I know what the general answer is going to be, but I'm hoping to ultimately get some good real world examples. Fire away! :) Regards, Peter Foti
145
8801
by: Mark Johnson | last post by:
Oddly enough, I found it difficult, using Google, to find a list of best-of sites based on the quality of their css packages. So I'd ask. Does anyone know of particularly good sites which are in good measure because of their creative and useful css designs? I'm aware of Zen Garden and a few others. So don't bother with those. And I hope I don't get replies from people with a 'tin ear' and no design sense. Good sites. Good pages. That's...
2
1681
by: JR | last post by:
Hi. I have a CGI script that will need to call itself an unknown number of times, to add rows, run queries, etc. At the bottom of the output that is produced by the script, there are four buttons. I need one of the buttons to simply be a back button. I have this button working fine. I need the second and fourth buttons to point to the current CGI script, but I need the third button to point to a different CGI script. I need the...
12
3904
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with both single quotes and no single quotes, but it doesn't work either way. What am I doing wrong? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById('weblogs').style.visibility='hidden';
4
5463
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs')
14
2781
by: Rudy | last post by:
Hello all! I been trying to get a handle with Images. I have learned alot from the fine people here. So, I also learned that thumbnail images look terrible taken from a digital cam. I know why they look bad. So what is the best way to resize an image. I'm not too concerned about size, but I guess I would like to compress it on the upload. Any thoughts?
7
1735
by: Rhino | last post by:
I thought I'd take a second to step away from a specific problem and ask a general question about best practices; I know some of the people here are very experienced with CSS. Given the need to have different CSS for printing than for screens, which of these two options is the best approach? 1. Have a single CSS for each media, then use different <link> tags for each media? 2. Have one CSS that includes all rules and use @media rules to...
2
1969
by: mikeoley | last post by:
Ok I have a Javascript slideshow working. Every image is linked to a another page in the site. Problem is...The link wont refresh to the next link once the second images rollovers in the slideshow. It only stays at the first images link. Is this a cache issue? Or is there anyway to create a random number to trick this or make it work properly. I'm very raw with Javascript so I'm having trouble figuring this out. Thank you in advance
0
8337
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
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
8748
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
8531
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
8628
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...
0
7359
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.