Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Ruth Chorney
2,689 PointsAccording to my EW 4 In HTML5 the <a> tag cannot contain a tag <h1, p> It shows up as an error.
According to my Expression Web 4 In HTML5 the <a> tag cannot contain a tag <h1> or a <p>. What is the correct answer?
Ruth Chorney
2,689 PointsI'm sorry Alex. Your answer doesn't make any sense to me. I think there are a bunch or words missing.
Alex Freeborn
1,707 PointsI'm a little new to answering questions and all the code I wrote got kind of wonky. I attempted to fix it, sorry...
Ruth Chorney
2,689 PointsI know what the anchor tag is for. The question was when you wrap a paragraph or a h1 or h2 with the <a></a> it shows an error in Microsoft Expression Web. I think it has something to do with putting a Block inside of an Inline. The comment from Expression web says a <p> or and <h1> cannot be inside of a <a> tag.
Alex Freeborn
1,707 Pointswhat are you linking your h1 and p tags to.
Ruth Chorney
2,689 PointsIt's part of the "How to build a website tutorial" by Nick Pettit. Here is the code
<a href="index.html" id="logo">
<h1>Ruth Chorney</h1>
<h2>Artisan</h2>
</a>
Alex Freeborn
1,707 Points<header> <a id="logo" href="index.html"> <h1>Alex Freeborn</h1> <h2>Developer</h2> </a> <nav> <ul> <li><a href="index.html" class="selected">Portfolio</a></li> <li><a href="about.html">About</a></li> <li><a href="contact.html">Contact</a></li> </ul> </nav> </header>
This is how mine looks. ignore the nav section if you haven't got there yet.
Ruth Chorney
2,689 PointsSame as mine Alex. I already went through the tutorial once but doing it again to get a better understanding. This time I am also building the site in Expression Web 4 at the same time. That is where I noticed the error. EW4 has a built in compatibility checker and it pointed out the issue. I was just curious about this so I asked. It's probably not worth being concerned over. Thanks again for your help.
1 Answer
Trace Harris
Python Web Development Techdegree Graduate 22,065 PointsI believe this will help answer the question, before html 5 you could not place block level elements between anchor tags (The browsers would not render them), now that html 5 has been standardized by the w3c web consortium it doesn't matter. Your issue probably is that the expression web 4 program may not have been updated to take this in therefore when it checks for compliance in your code it is throwing an error because it is comparing it to pre html 5. If you have any doubts check your code here https://validator.w3.org/ just choose the direct input tab at top and copy and paste. the service will notify you of any problems within you html.
Alex Freeborn
1,707 PointsAlex Freeborn
1,707 PointsThe a tag is used to create links, an example of this would be a href="website url">site name /a (So you could see the code I had to mess with the link a little, sorry....) The h1 and p tags do not belong inside of the a tag. But you can use the p tag, and others in conjunction with the a tag to create links to other websites. Hope this helps.