Which is the proper way?

  • mista-two-k
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Oct 15, 2007
  • Posts: 57
  • Status: Offline

Post November 15th, 2011, 5:53 am

Hey everyone,

Currently, I insert my images with the following code:

Code: [ Select ]
<div class="overlay alignleft" style="width:200px; height:180px;>
    <a href="big.jpg" title=""><div class="some class"></div></a>
    <img src="thumb.jpg" alt="" />
</div>
  1. <div class="overlay alignleft" style="width:200px; height:180px;>
  2.     <a href="big.jpg" title=""><div class="some class"></div></a>
  3.     <img src="thumb.jpg" alt="" />
  4. </div>


But I read somewhere that you should never put a block level element <div> inside an inline level element <a>. My WordPress theme is XHTML. So my question now is whether the above mentioned code is considered as OK in perspective on an XHTML document. If not, could anyone suggest me a better way?

Thanks
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post November 15th, 2011, 5:53 am

  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post November 15th, 2011, 4:04 pm

You could use a span tag instead and apply whatever class you want to that. Those are allowed inside <a> elements.
Ozzu Hosting - Want your website on a fast server like Ozzu?
  • mista-two-k
  • Beginner
  • Beginner
  • No Avatar
  • Joined: Oct 15, 2007
  • Posts: 57
  • Status: Offline

Post November 15th, 2011, 4:18 pm

Hi, thanks for replying.

I tried replacing the div with a span tag, but now the hover isn't properly positioned. The thing is, I have an image overlay which nicly cover the whole image on hover. But when using the span tag it is slightly off-set...?

Is it bad to use the code I am currently using?

Thanks
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Joined: Dec 20, 2002
  • Posts: 8934
  • Loc: Seattle, WA & Phoenix, AZ
  • Status: Offline

Post November 15th, 2011, 8:28 pm

In your CSS, apply this to the span tag:

display:block;

That may resolve your issue.
Ozzu Hosting - Want your website on a fast server like Ozzu?

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 138 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.