Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > HTML, XHTML and CSS

Reply
 
LinkBack Thread Tools
Old November 30th, 2007, 03:54 AM   #1
Reputable Member
 

Join Date: May 2007
Location: Margate
Age: 26
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 R8515198 is on a distinguished road
[SOLVED] How to make a div a link

Hi all,
I have a div with a background image, and am trying to make the div a link. A class sould be easier as then I could apply it to rest of the buttons.

Any help will be greatly appreciated

Dan

Code:
#CMS{
 background-image: url(assets/buttons/right/blue_CMSbutton.gif);
 background-repeat: no-repeat;
 background-position: center center;
 height: 40px;
 width: 150px;
 margin-left: 15px;
}
HTML Code:
<div id="CMS"></div>
R8515198 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old November 30th, 2007, 03:57 AM   #2
WebForumz Admin Badge
SuperMember
 
Marc's Avatar
 

Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
Rep Altering Power: 89 Marc is just really nice Marc is just really nice Marc is just really nice Marc is just really nice
Re: How to make a div a link

You would have to do something like:
HTML Code:
<a href=""><div id="CMS"></div></a>
although i would opt for a <span> rather than a <div>.
__________________
Regards
Marc
Administrator - Webforumz.com

Web Design and Development Blog - Marc Fraser
Marc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old November 30th, 2007, 04:09 AM   #3
Reputable Member
 

Join Date: May 2007
Location: Margate
Age: 26
Posts: 157
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 R8515198 is on a distinguished road
Re: How to make a div a link

Nice and simple

Cheers

Marc
R8515198 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old November 30th, 2007, 04:11 AM   #4
WebForumz Admin Badge
SuperMember
 
Marc's Avatar
 

Join Date: Apr 2007
Location: Scotland, UK
Posts: 2,086
Thanks: 2
Thanked 23 Times in 23 Posts
Rep Altering Power: 89 Marc is just really nice Marc is just really nice Marc is just really nice Marc is just really nice
Re: [SOLVED] How to make a div a link

Your welcome - that's what I'm here for!
__________________
Regards
Marc
Administrator - Webforumz.com

Web Design and Development Blog - Marc Fraser
Marc is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old November 30th, 2007, 04:25 AM   #5
Most Reputable Member
 

Join Date: May 2007
Location: UK
Age: 29
Posts: 1,107
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 MikeHopley is just really nice MikeHopley is just really nice MikeHopley is just really nice MikeHopley is just really nice MikeHopley is just really nice
Re: [SOLVED] How to make a div a link

As Marc said, you should use a <span>, not a <div>. If you use a <div>, you will likely make invalid code.

As a general rule, don't put block-level elements (such as <div>) inside inline elements (such as <a>). See this W3C explanation:

Quote:
Content model

Generally, block-level elements may contain inline elements and other block-level elements. Generally, inline elements may contain only data and other inline elements. Inherent in this structural distinction is the idea that block elements create "larger" structures than inline elements.
You can have the appearance of a <div> by using the CSS:

Code:
span.block { display: block; }
This trick is commonly applied to <a> elements in navbars.

Last edited by MikeHopley; November 30th, 2007 at 04:43 AM..
MikeHopley is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make a div become visible on clicking a link? snappy HTML, XHTML and CSS 12 June 11th, 2008 03:25 PM
[SOLVED] How to make an expand / collapse menu sing2trees JavaScript 4 April 14th, 2008 08:16 AM
[SOLVED] joining 2 queries together to make 1 query AdRock Databases 0 November 18th, 2007 05:37 PM
[SOLVED] How do I Make Content available for download chrissmith Your Design and Layout 4 November 11th, 2007 06:13 AM
[SOLVED] How to make the PM pop up box? Monie JavaScript 31 November 7th, 2007 04:38 AM


Search Engine Optimization by vBSEO 3.2.0 RC8