| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
stephen eighmey
Join Date: Oct 2006
Location: earth
Posts: 152
|
css background image as hyperlink?
i usually make my site logo (in the top, upper left) a hyperlink to the home page of the site. i'm now starting to place all my images as css background images to truly separate content and presentation. is there a way to assign a hyperlink to the css background image so it validates as xhtml strict (with the correct mime type)? thank you. |
|
|
|
|
|
#2 (permalink) |
|
For all your goober needs
Join Date: Dec 2004
Location: Coventry, UK
Posts: 1,528
|
put in the a display: block height and width position absolute if you need to but float left is preferable and you're done. bear in mind your logo won't print if you do it the way that you're doing this. Time is really the only capital that any human being has, and the one thing that he can’t afford to lose. - Thomas Edison
prem ghinde |
|
|
|
#4 (permalink) |
|
For all your goober needs
Join Date: Dec 2004
Location: Coventry, UK
Posts: 1,528
|
put the anchor inside the div that the background image is attached to yes Time is really the only capital that any human being has, and the one thing that he can’t afford to lose. - Thomas Edison
prem ghinde |
|
|
|
#6 (permalink) |
|
Senior Member
Join Date: Jan 2005
Posts: 12,358
|
I usually put the logo in the markup (unless I'm using some kind of image replacement technique). That way I can include it in the print stylesheet. There's nothing wrong with putting images in markup if they're content. Now, you could argue both ways with a logo - it's essential branding, the identity of your company. Does that make it content? Maybe. Also, float: left; (if you use it) will automatically set it to display: block. No need for both. If I use image replacement for the logo (i.e. if it's a logotype and not a graphic), I'll usually do something like this: HTML Code:
Code:
Con: Difficult to make it print. Otherwise, it's just: HTML Code:
Con: SEO and graphics in markup (not that that's always a bad thing). |
|
|
|
#9 (permalink) | |
|
Senior Member
Join Date: May 2006
Posts: 462
|
Quote:
block elements are on their own line though. ex: Block and floated boxes modified htmldog example |
|
|
|
|
#12 (permalink) | |
|
Senior Member
Join Date: Jan 2005
Posts: 12,358
|
What makes a <p> a block? Floatutorial: Float basics Quote:
|
|
|
|
|
#13 (permalink) |
|
Senior Member
Join Date: Sep 2006
Posts: 276
|
I always use the text indent function personally. Like others have said do display block and set the width and height. If for example you use <li> elements with links for navigation as is the norm then it works well. Once you use the display block and set width height and background then add in text-indent: -9999px; and you are all set. This way there is no need to introduce a span into your coding. HTML Code:
Code:
Of course if you want to get super special look at naviagtional matrix technique for menus as this way you create a one block navigational image and use css to create the rollovers and different buttons from this one image (the image holds all your states on one piece which is often a shorter load than loading all individual images separately). And usually you use the link inside a div or <li> element so I usually give that element the id then use the css selector to select the tags within that element rather than actually assign the id to the tag. |
|
|
|
#14 (permalink) | |
|
Registered User
Join Date: Mar 2007
Location: Northampton UK
Posts: 17
|
Quote:
I have never tried this but… You could combine both: HTML Code:
Screen stylesheet Code:
Print stylesheet Code:
I usually just hide my span I like way you have done it. |
|
|
![]() |