Reply
Basic H1 image replacement
Old 04-27-2008, 08:40 AM Basic H1 image replacement
dave9713's Avatar
Ultra Talker

Posts: 257
Name: David
Location: London
Hi All,

What would be the easiest way to place my h1 tags beneath an image? Everything I seem to try just moves the page layout around ...

URL www.portfolio-properties.net

Thanks,

Dave
__________________

dave9713 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-27-2008, 09:00 AM Re: Basic H1 image replacement
chrishirst's Avatar
Super Moderator

Posts: 11,505
Location: Blackpool. UK
A relative positioned container, position absolute and z-index of 1 for the heading so it is out of the document flow and below other elements then use position relative (or absolute) and z-index 10 for the image.

That way the container is part of the layout, while the heading and the image are isolated.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-27-2008, 12:07 PM Re: Basic H1 image replacement
dave9713's Avatar
Ultra Talker

Posts: 257
Name: David
Location: London
Thanks Chris works a treat

Dave
__________________

dave9713 is offline
Reply With Quote
View Public Profile
 
Old 05-02-2008, 09:57 AM Re: Basic H1 image replacement
nickohrn's Avatar
Weightlifting CS Student

Posts: 505
Name: Nick Ohrn
I would recommend another technique. First, set the image as the background image on your h1 tag, and keep the h1 tag where it is. Set the property text-indent on the h1 tag to some ridiculously negative value like -1000000px. This will hide the h1 text while still keeping the semantic meaning of the element. Be sure to set an explicit height and width on the element that is the same size as your image.
__________________
Plugin-Developer.com - Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
nickohrn is offline
Reply With Quote
View Public Profile Visit nickohrn's homepage!
 
Old 05-04-2008, 03:55 PM Re: Basic H1 image replacement
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Why are you complicating it?

HTML Code:
<h1 style="height: XX; width: XX; background: url(image.jpg) top left no-repeat"><span style="visibility: hidden;">Heading 1 Text</span></h1>
__________________
Tumblings.co.uk - Tumblog with thoughts, quotes, links, videos, images and my creations.
Opera Browser - The best free web browser.
Opera Dev Tools - Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 05-04-2008, 04:58 PM Re: Basic H1 image replacement
nickohrn's Avatar
Weightlifting CS Student

Posts: 505
Name: Nick Ohrn
Mooofasa, I don't like that text because I don't think screen readers will pick up on the text if its visibility is set to hidden. I'm not sure though.
__________________
Plugin-Developer.com - Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
nickohrn is offline
Reply With Quote
View Public Profile Visit nickohrn's homepage!
 
Old 06-09-2008, 09:37 AM Re: Basic H1 image replacement
Mooofasa's Avatar
Defies a Status

Posts: 1,611
Name: Michael (mik) Land
Location: England
Then use display: none.
__________________
Tumblings.co.uk - Tumblog with thoughts, quotes, links, videos, images and my creations.
Opera Browser - The best free web browser.
Opera Dev Tools - Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 06-10-2008, 02:43 PM Re: Basic H1 image replacement
Arenlor's Avatar
Ultra Talker

Posts: 463
Name: Jerod Lycett
Location: /home/arenlor
Most screen readers obey display:none;
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-10-2008, 08:49 PM Re: Basic H1 image replacement
Convert2Steve's Avatar
Experienced Talker

Posts: 35
Name: Steve Howe
Location: Salt Lake City
I prefer this method where you move the text off the screen (text-indent: -9999px; or any arbitrary large negative figure) to the image replacement technique.

Personally this is how I do it:

h1, p.welcome, ul#nav li a {
display: block;
overflow: hidden;
font-size: 0.0; line-height: 0.0;
text-decoration: none; text-indent: -9999px;
background: transparent no-repeat 0 0;
}
h1 {
height: 20px; width: 500px;
background-image: url(header.img);
}
p.welcome {
height: 150px; width: 350px;
background-image: url(welcome.img);
}

This code easily allows for more elements to be replaced. Simply add the selector to the main replacement code, then create a separate declaration with the height, width and path to the appropriate image.

The display: block allows for the image replacement to be used on inline elements (such as anchors) with no extra code. The 0.0 on font-size and line-height are for bugs in the validator (!). And the overflow: hidden; trims the unsightly long 'focus halo' introduced in Firefox 1.5, so that is only the width of the content.
__________________
Convert2Media Affiliate Network |"We beat the street!"
phone:
(801) 413-3037 | aim: Convert2Steve | skype: Convert2Steve
Convert2Steve is offline
Reply With Quote
View Public Profile Visit Convert2Steve's homepage!
 
Reply     « Reply to Basic H1 image replacement
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14545 seconds with 13 queries