473,440 Members | 1,843 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,440 software developers and data experts.

clickable css image

1
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 14556
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 Expert 256MB
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 Expert 512MB
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...
0
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...
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...

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.