css anyone?

Discussion about the creation of websites in general, HTML, PHP, Java.

css anyone?

Postby arn0ld on Mon Sep 04, 2006 9:38 pm

Hmm, so these past few days I've been reading about CSS. I've learned that CSS is able to make your site compatible both on text-based and graphics-based browsers. One good technique that I've been reading about is the Image Replacement. I've seen lots of authors have found a way to replace text with image. One code goes like this: (correct me if I'm wrong)

Code: Select all
html:
<h1 id="header"><span>Header</span></h1>

CSS:
#header {background: url('headerImage.gif') no-repeat; width: 200px; height: 100px}
span {display: none}

It works fine when it comes to plain text or headers but I'm having a problem on doing the same thing on links - replacing link with an image. If anyone has an idea on how to do this that also works on browsers like FF, IE, and Opera, please do help me.

Thanks in advance Wink
...in a sea of strangers where everybody is just a face, a person can stand out with a smile
May gina-admire ako galing nahuya ko magstorya sa iya nga face-to-face!!
arn0ld
Regular
Regular
 
Posts: 110
Joined: Fri Mar 31, 2006 7:09 pm
Location: Las Phelippinas

Postby Willyham on Wed Sep 06, 2006 12:58 pm

I'm not sure what you mean by replacing text with images, but you can 'stack properties' somewhat like this, for example:

Code: Select all
#banner {
     background-colour: #000000;
     etc;
     etc;
}
#banner a {
     style links here;
     style only applies for inside #banner div
}


So the relevent HTML would be:

Code: Select all
<body>
<div id="banner">
<a href="this is styled" />
</div>
<a href="this is not styled" />
</body>
Image
Willyham
Contributer
Contributer
 
Posts: 32
Joined: Sun Aug 27, 2006 3:51 pm
Location: Nottingham, England.

Postby slashfoo on Wed Sep 06, 2006 3:06 pm

I do not think this can be done solely by CSS styles, If I got your question correctly, you want to replace the link text with an image, keeping the hyperlink.

If so, you'd want to look into cgi or preprocessing (php or perl to parse your files beforehand) if you are into web programming, if you pick this way, you can PM me with a more specific question or more details of what you want to do and I will be happy to help.

However if you are not interested in those, and still find an answer to your needs, it would be good if you let me know as well, extra know-hows are never bad.
Slashfoo
"Hello my friend, stay a while and listen..."
--- Deckard Cain (Diablo game)
slashfoo
Contributer
Contributer
 
Posts: 70
Joined: Tue Sep 05, 2006 12:44 pm

Postby arn0ld on Wed Sep 06, 2006 9:07 pm

Thanks for the answers. I've also found one tutorial and it exactly uses CSS. Nice eh. Laughing
Here's the link:
http://www.cssplay.co.uk/menus/flickerfree_mk3.html
Check it out if you want Wink
...in a sea of strangers where everybody is just a face, a person can stand out with a smile
May gina-admire ako galing nahuya ko magstorya sa iya nga face-to-face!!
arn0ld
Regular
Regular
 
Posts: 110
Joined: Fri Mar 31, 2006 7:09 pm
Location: Las Phelippinas

Postby callihn on Sat Sep 09, 2006 7:48 am

arn0ld wrote:Thanks for the answers. I've also found one tutorial and it exactly uses CSS. Nice eh. Laughing
Here's the link:
http://www.cssplay.co.uk/menus/flickerfree_mk3.html
Check it out if you want Wink


What's the purpose behind using CSS for that?
callihn
Regular
Regular
 
Posts: 77
Joined: Thu Jul 27, 2006 2:35 pm
Location: Cyberspace

Postby De Kus on Sat Sep 09, 2006 11:28 pm

Why not simply use the alt attribut of the img tag? Very Happy
It's required by W3.org's HTML 4.0 Recommendation for exactly the reason to be compatible with text based browsers.
Image
User avatar
De Kus
Phoenix Veteran
Phoenix Veteran
 
Posts: 305
Joined: Mon Mar 14, 2005 2:15 pm
Location: Germany

Postby trick on Mon Sep 11, 2006 3:17 am

Yeah, for some reason image replacement has been popular among CSS junkies like csszengarden.com but you should definitly not use it. It's retarded, and actually makes it worse for screen readers.
'The military don't start wars. Politicians start wars' - William Westmoreland
Image
trick
Contributer
Contributer
 
Posts: 74
Joined: Mon Aug 07, 2006 6:07 am

Re: css anyone?

Postby aLPHa_LeaK on Sat Sep 23, 2006 10:15 pm

arn0ld wrote:
Code: Select all
html:
<h1 id="header"><span>Header</span></h1>

CSS:
#header {background: url('headerImage.gif') no-repeat; width: 200px; height: 100px}
span {display: none}


That is just plain stupid. Use images with alt-tags to display text to screen readers. For example:
Code: Select all
<h1><img src="bla.jpg" alt="Header" /></h1>

No CSS needed.
aLPHa_LeaK
Contributer
Contributer
 
Posts: 23
Joined: Sat Sep 23, 2006 9:57 pm


Return to General Webmastering

Who is online

Users browsing this forum: No registered users and 1 guest

cron