473,466 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

clickable css image

1 New Member
Hi, I want to have a click able image in my web, that link to my homepage.
Ref: http://www.w3schools.com/Css/tryit.asp?filename=trycss_background-
attachment and a click here should transfer to my homepage (index.html)

I dont easily find a working example, and my knowledge of css is very low.

Please help me.

Oddvar
Oct 12 '08 #1
3 14560
labmonkey111
44 New Member
Are you saying you want the background image to be clickable? Because as far I know that is not possible (at least not without some JavaScript). If all you want is an image that is a link, try:

Expand|Select|Wrap|Line Numbers
  1. <a href="your url here"><img src="your image path here"></a>
  2.  
Oct 12 '08 #2
David Laakso
397 Recognized Expert Contributor
A background image can't have a behavioral property with CSS. But there is a "trick" you /may/ be able to employ: apply the background image to the link. Please see: CSS Trick
Oct 12 '08 #3
JamieHowarth0
533 Recognized Expert Contributor
I've used that trick many a time.

For the benefit of the OP (and anyone else who might find it useful) you can set a background image on a section of text (normally a heading) and then add a link to it.

Let's say you have the following HTML code:

Expand|Select|Wrap|Line Numbers
  1. <a href="homepage.html"><img src="images/yourlogo.gif" alt="Your Company Name" /></a>
  2.  
Now, we all know that search engines prefers images over text, right? So we'd rather have a nice big <h1> in there with our company name so search engines find the text, but we still want to show off our fancy company logo that we spent thousands of dollars on a bunch of clever marketing and design guys to come up with.

Expand|Select|Wrap|Line Numbers
  1. <h1 class="logo"><a href="homepage.html">Your Company Name</a></h1>
  2.  
So how do we get the logo in there in an invisible manner?

Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2. <!--
  3. h1.logo {background:url("images/yourlogo.gif") no-repeat top right;}
  4. a {display:block; height:150px; width:300px; text-indent:-9999px;}
  5. --></style>
  6.  
What we've done is put the background image on the h1 tag, and set the link to be a block-level element. This means we can control it's height and width a bit better than an inline element.

So when you view your page with no CSS (as search engines do), they'll see a nice, big, H1 tag - great for getting the PageRank up for your company name. But when users with modern browsers view it, they'll get the eye-catching benefit of that oh-so-expensive logo.

codegecko
Oct 12 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Tipper | last post by:
I am trying to create a clickable image for use within an MFC VC++ application. The requirement is for the control to generate messages on click or double click etc for different areas of the...
53
by: Kerberos | last post by:
I followed Dan Cederholm's image replacement tutorial, to replace a header tag by a logo. The h1 is clickable if no CSS is applied but it I replace it by the logo, the area isn't clickable anymore...
5
by: Matt Bostock | last post by:
Hi, Please see: http://www.drfunkenstein.net/catalogue/categories/fancydress/81/go/2/ ...and try clicking on the '< previous' link underneath the costume thumbnails. The link is only...
9
by: Lando Chez | last post by:
Hi I need a map of a country on which a region( part of the map) can be clicked ( or on mouseover) causing, on another part of the same page, the appearance of information regarding the region....
12
by: Ted Weatherly | last post by:
Is it possible to create a clickable time zone map on a web page? Is it as simple as finding an image of world time zones and declaring a bunch image map coordinates? Has someone already done...
9
by: Paul W | last post by:
I'm using a Table webcontrol to display a 'grid' to the user. Various cells should be 'clickable' by the user (to run javascript). How can I make this happen? (currently I use the background cell...
1
by: =?ISO-8859-1?Q?Fran=E7ois_de_Dardel?= | last post by:
The URL is: http://dardel.info/tintin/random.html What I want to achieve: When you click a thumbnail, a window opens with a larger copy of the pict _as the background_. I want the new window...
3
by: crazychrisy54 | last post by:
Hi there I just wondered if there is any way using GD to insert a clickable button or some clickable text into a image? It is possible to create images for buttons but what if you want a...
3
by: breakupemail | last post by:
Hello, on my website at http://www.breakupemail.com/ there is a horizontal navigation bar with 6 hyperlinks. Recently, I added a second navigation row below the first, with 2 links. Once this...
2
by: GloStix | last post by:
For some reason, FF likes to put a black underline on all my buttons. No matter what I do, it has the line I've tried displaying as block and cursor, anything.. Also I've been trying to get it so...
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
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,...
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.