English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories
0

I know somewhere I found info about how to make a strip of text and it's surrounding area clickable by using some sort of Span command?

Can someone tell me how to use it and if possible, can the area around the text be a different colour AND change colour when the mouse is over it?

Thanks!

2006-11-26 08:45:17 · 2 answers · asked by crafty1980 1 in Computers & Internet Programming & Design

2 answers

First, if you want to make a link, you should use the anchor element, not a span or any other element. Let's do things correctly :)

quick example:

HTML:

My Text

CSS:

.button {
padding: 20px; /* create a 20 pixels wide area around your text */
background-color: red; /* set button area color */
color: black; /* set text color */
}
.button:hover {
background-color: blue; /* :hover means when move is over */
color: inherit; /* reuse same color -optional but good practice to define it */
}

there you have a red box with 'My Text' written in black in it. Move your move over the button and the box color will change to blue.

2006-11-26 09:17:37 · answer #1 · answered by Cedric 2 · 0 0

you can do it with just a span by throwing an onclick='javascriptfunction',

to color it differently you need css. throw in a style="color:red"

so you have this is red

the javascript might set document.location to a url

when that becomes tiring, you can also do it with advanced dom manipulation and then the html becomes
this is red
and the javascript gets more exciting!

2006-11-26 19:26:22 · answer #2 · answered by jake cigar™ is retired 7 · 0 1

fedest.com, questions and answers