January 6, 201115 yr Hey All, I have a class called basket, within this class I have a background image as I wanted to overlay text, is there any way for me to make that whole div class a link? ie: <div class="shoppingBasket"> <p class="items">Currently 0 item/s in basket</p> </div> Can I add a link to the overall div? Wayne Edited January 6, 201115 yr by waynede
January 6, 201115 yr Author Can a mod please close the thread I believe that I have sorted it using JS onclick <div class="shoppingBasket" onclick="location.href='http://www.waynedeboer.co.uk/'" style="cursor: pointer;"> <p class="items">Currently 0 item/s in basket</p> </div>
January 6, 201115 yr This thread might help you: http://www.webdesignerforum.co.uk/topic/43287-clickable-div-as-link-plus-rollover/page__view__findpost__p__272531
January 6, 201115 yr Author bear in mind that the "onclick" version is not SEO friendly. Thankyou, is their an SEO friendly way of doing what is needed?
January 6, 201115 yr Wrap the Div in an anchor tag. <a><div>Stuff</div></a> Give the Div a style of "cursor:pointer". You might need to also remove any text that gains an unwanted underline. "text-decoration:none"
January 6, 201115 yr Do it the way explained in the thread link I posted, all you need to do is make the whole thing a link instead of a div, and if you can't style your text using the basket class and need the items class change it from <p> to <span>. Link again if you can't be bothered to look up: http://www.webdesignerforum.co.uk/topic/43287-clickable-div-as-link-plus-rollover/page__p__272531#entry272531 EDIT: Daz you don't need the div in the link like you have done it just needs to be is : <a>Currently 0 item/s in basket</a> Edited January 6, 201115 yr by Dizi
January 6, 201115 yr Author Okies, thankyou both for the help, I am reading the post at the moment, I missed it 1st time round as you posted straight after I responded with the onclick. Thanks again.
January 6, 201115 yr EDIT: Daz you don't need the div in the link like you have done it just needs to be is : <a>Currently 0 item/s in basket</a> So the <a> tag combined with a <span> or <p> would do all that a <div> can do? Learn something new everyday.
January 6, 201115 yr You can't combine it with a <p> well you can you can have@ <p><a>something </a></p> But you can't have <a><p>something</p></a> as link tags are inline unless you tell them through css to be block, but even then the site won't validate as you can't have a block within an inline, only inlines within a block.
January 10, 201115 yr You can't combine it with a <p> well you can you can have@ <p><a>something </a></p> But you can't have <a><p>something</p></a> as link tags are inline unless you tell them through css to be block, but even then the site won't validate as you can't have a block within an inline, only inlines within a block. So the only reason not to do that method is full validation? That's not too bad then.
Create an account or sign in to comment