The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Including an inline image in a link
hmlewis19
post Mar 17 2008, 02:12 AM
Post #1





Group: Members
Posts: 3
Joined: 15-March 08
Member No.: 5,208



I am a novice when it comes to HTML and CSS. So please don't think my questions are stupid!! I need all the help I can get!!

How can I enclose an inline image and paragraph within a link with the href attribute "#".

This is what I have got:

<a href="#"><img src="image5.jpg" alt="" /><br />
<p>
<span>9:30 a.m.</span> It's time to go through
the Keyhole. Be prepared for heavy winds.
</p>
</a>


Could someone please tell me if this is right???

PLEASE!!

Any help would be greatly appreciated....

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Mar 17 2008, 02:48 AM
Post #2


Jocular coder
********

Group: Members
Posts: 2,460
Joined: 31-August 06
Member No.: 43



What is supposed to be the effect of clicking a link to '#'? I don't think it will take you anywhere....

Otherwise, yes, you can include (almost) any html content within the <a>... </a> tag, and this content will be the stuff that, when clicked, takes you to the place in the href=xyz page.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Mar 17 2008, 03:00 AM
Post #3


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



You can't have a block level element (<p>) within an inline element (<a>). The online validator would point that out.

So, you'll have to code it differently. See for an example at http://www.smileycat.com/miaow/archives/000230.php. Here a list is used and an <em> element set to "block".
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Frederiek
post Mar 17 2008, 05:57 AM
Post #4


Programming Fanatic
********

Group: Members
Posts: 5,146
Joined: 23-August 06
From: Europe
Member No.: 9



I just found yet another sample site (yet again based on Veerle's blog) at http://samrayner.com/archives/building_a_better_blocklist/.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Mar 17 2008, 10:46 AM
Post #5


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



Another approach is to restructure your markup. You could move the image and anchor into the paragraph:
CODE
<p><a href="...">
  <img src="..." alt="..."><br>
  <span>9:30 a.m.</span> It's time to go through the Keyhole. Be prepared for heavy winds.
</a></p>
You could create multiple anchors:
CODE
<a href="...">
  <img src="..." alt="...">
</a><br>
<p><a href="...">
  <span>9:30 a.m.</span> It's time to go through the Keyhole. Be prepared for heavy winds.
</a></p>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 26th April 2024 - 07:55 PM