Why don't these 3 lines validate? (XHTML)

  • Tojiro
  • Newbie
  • Newbie
  • Tojiro
  • Posts: 9

Post 3+ Months Ago

Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<a href="#"><h6>Heading</h6></a>
<a href="#"><img src="#" alt="Front view" width="72" height="72" /></a>
<p>Lorem ipsum dolor sit amet...</p>

</body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. </head>
  7. <body>
  8. <a href="#"><h6>Heading</h6></a>
  9. <a href="#"><img src="#" alt="Front view" width="72" height="72" /></a>
  10. <p>Lorem ipsum dolor sit amet...</p>
  11. </body>
  12. </html>


I'm entirely self-taught, so there's likely some rule I've never learned before, but it's really bugging me!

Thanks!
  • Zwirko
  • Guru
  • Guru
  • User avatar
  • Posts: 1417
  • Loc: 55° N, 3° W

Post 3+ Months Ago

Just put the links inside the heading:

Code: [ Select ]
<h6><a href="#">Heading</a></h6>


and all shoud be fine.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

Zwirko wrote:
Just put the links inside the heading:

Code: [ Select ]
<h6><a href="#">Heading</a></h6>


and all shoud be fine.

Yeah, a heading tag is a parent tag and a link could be as a child.

Same way that it works with <div>'s and <span>'s. A <span> is a child tag (Means it can go between <div>...</div> or <p>...</p> and some other tags) but a <div> is a parent tag (Means it can't go between anything... <p><div>...</div></p> won't validate).

That's the simple rule your missing... parent tags versus child tags. You gotta know what is what :) (I'm self-taught too by the way... was learning myself for about 3.5 years now :D )
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6254
  • Loc: Seattle, WA

Post 3+ Months Ago

That's not exactly the case, Bogey.

<div> elements are generic block elements by default.
<span> elements are generic inline elements by default.

That's the difference between the two. It doesn't really have to do with the parent/child relationship.
  • JISForums
  • Born
  • Born
  • JISForums
  • Posts: 3

Post 3+ Months Ago

Didya put the links on <a href=Websiteaddresshere></a>
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8416
  • Loc: USA

Post 3+ Months Ago

spork wrote:
That's not exactly the case, Bogey.

<div> elements are generic block elements by default.
<span> elements are generic inline elements by default.

That's the difference between the two. It doesn't really have to do with the parent/child relationship.

Oh, I see...

I'm still learning :lol:
  • righteous_trespasser
  • Scuffle
  • Genius
  • User avatar
  • Posts: 6229
  • Loc: South-Africa

Post 3+ Months Ago

JISForums wrote:
Didya put the links on <a href=Websiteaddresshere></a>

What?

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 19 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.