I tried to validate my HTML code but I got this error:
Line 157, Column 22: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag <div class="details">
The mentioned element is not allowed to appear in the context in
which you've placed it; the other mentioned elements are the only ones
that are both allowed there and can contain the element mentioned.
This might mean that you need a containing element, or possibly that
you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put
a block-level element (such as "<p>" or "<table>") inside an inline
element (such as "<a>", "<span>", or "<font>").
but I cant see any mistake in my code, so I am asking for help...
<!--Bar 3-->
<div class="mosaic-block bar3">
<a href="http://www.desktopped.com/featured/2010/09/multi-d isplay-setup-with-four-systems-and-a-whole-lot-of- screen-space/" target="_blank" class="mosaic-overlay">
<div class="details">
<h4>Multi-Display Setup With Four Systems, A Wall of Screens, And 64TB Of Storage</h4>
<p>via Desktopped</p>
</div>
</a>
<img src="http://buildinternet.s3.amazonaws.com/projects/mos aic/64tb.jpg" alt="fotka1"/>
</div>
Blocks can't be placed in inline elements. In this case a is inline, and div is block, so <a><div></div></a> is invalid HTML.
Related
I'm new to html, I try to put a link("a"), a text "b", and a link "c" together in the same line. Here is my code.
<a class = "fixed" href="/a/">linka <span> b </span> <span> linkc </span> </a>
But I got some errors, like:
Start tag "a" seen but an element of the same type was already open.
error: End tag "a" violates nesting rules.
error: Stray end tag "span".
error: Stray end tag "a".
I try to get rid of nested , but the linkC would not show up. How to fix this error?
This error ish happening because you have a <a> tag nested within the first <a> tag, which is not allowed in HTML. To achieve the layout you're looking for, you can use a different approach that doesn't involve nesting <a> tags.
One way you could fix this is to use a container element, such as a <div>, to wrap all the elements together.
Example:
<div class="fixed">
linka
<span> b </span>
linkc
</div>
Imagine this block of HTML:
<a href="/somewhere/">
<div class="nested">
<div class="sub-nested">
<div class="sub-sub-nested">
button
</div>
</div>
</div>
</a>
This gets rendered in my browsers like this:
<div class="nested">
<div class="sub-nested">
<div class="sub-sub-nested">
button
</div>
</div>
</div>
This happens only if there is another a tag inside the outer a tag.
I totally don't understand why this is happening. How this could even be. And it's driving me insane.
The problem looks so basic, that i wonder what it was about the HTML standard that i have misunderstood? After all, shouldn't as of HTML5 any tags be allowed within a tags?
What am i missing here?
You can't next anchor tags. As the W3 says:
12.2.2 Nested links are illegal
Links and anchors defined by the A element must not be nested; an A
element must not contain any other A elements.
If you try to validate your code, you will get
Document type does not allow element "div" here; (...)
One possible cause for this message is that you have attempted to put
a block-level element (such as "<p>" or "<table>") inside an inline
element (such as "<a>", "<span>", or "<font>").
So you can't put a <div> inside an <a>.
To expand a bit on why you can't nest A tags, the browser would not know where to direct the user, since the multiple A tags would have multiple HREF attributes. This is why it is illegal to nest A tags.
Right after my <body>, as part of the header I add to each page, is my site's logo. This <img> is within an <a> tag, pointing to my index page.
Here's what W3C validator
Line 21, Column 38: document type does not allow element "a" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag
(I would past the rest of the message, but the html tags in it get messed up, I don't know how to escape them within a blockquote).
What's the proper place to put an logo? Logically, it's not within a division. Making a blank container element seems rather silly.
Local source:
...
<body>
<a title="Home" href="index.html"><img src="images/logo.png" id="logo"/></a>
....
Complete source: http://pastie.org/5998955
That error is error is referring to you placing an inline block element, without a container block.
You'll have to do something like this to get it valid:
<body>
<div><a title="Home" href="index.html"><img src="images/logo.png" id="logo"/></a></div>
The error clearly states this, and even suggests what tags you can use to correct the issue.
If you want to use XHTML, then you're going to have to wrap inline elements in block elements to validate.
You could use HTML5 to do what you're doing and have it validate (but you'll have to add alt attributes to your images).
Pastie: http://pastie.org/5998964
Your problem is not "where to put the site's logo", your issue is malformed HTML based on the doctype you have specified in your head section.
A is an inline tag and needs to be wrapped by a block-level tag such as P or DIV.
this is the page - http://www.class-a-studio.co.il/contact.php
Column 23: document type does not allow element "LINK" here
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
i dont no what to do...?
As per the HTML 4 spec, the <link> element is only allowed inside the <head> element in your document. Perhaps you mean to use <a> element here?
<div class="buttons">
<a href="#" class="link1"
onclick="document.getElementById('form').submit()">
<em><img src="images/formB.jpg" alt="שליחה"></em>
</a>
<link href="tenks.php">
</div>
Perhaps needs to be
<div class="buttons">
<a href="#" class="link1"
onclick="document.getElementById('form').submit()">
<em><img src="images/formB.jpg" alt="שליחה"></em>
</a>
tenks
</div>
My Code below is generated from a StaticItemTemplate in an ASP:Menu.
The code and the link does as it pleases, however it fails validation.
Output code is as follows
<li>
<a class="level1 StaticMenuItemStyle" href="/Services.aspx">
<div class="StaticMenuItemStyle"
onmouseover="style.backgroundColor='#0088CB';style.color=white;"
onmouseout="style.backgroundColor='';"
style="color:Color [Blue];width:180px;">
Services
<br />
<div style="background-color: Blue; width: 180px;height: 5px;"></div>
</div>
</a>
</li>
however this errors on W3Validator
Line 84, Column 63: document type does not allow element "div" here; missing one of
"object", "ins", "del", "map", "button" start-tag
style="color:Color [Blue];width:180px;">
The mentioned element is not allowed to appear in the context in which you've placed
it; the other mentioned elements are the only ones that are both allowed there and
can contain the element mentioned. This might mean that you need a containing
element, or possibly that you've forgotten to close a previous element.
One possible cause for this message is that you have attempted to put a block-level
element (such as "<p>" or "<table>") inside an inline element (such as "<a>",
"<span>", or "<font>").
However if i replace the DIV with a span it validates. but doesnt look right. Anyone got any ideas how to get round this ?
Inside a "a" tag, div is not validate, because div is a basically block section and default style is section block. http://webdesign.about.com/od/htmltags/a/aa011000a.htm. But for anchor tag, it is same like as span. You can use onclick attribute on the div attribute or use .click function by jquery.
You can use it like below:
<li>
<a class="level1 StaticMenuItemStyle" href="/Services.aspx">
<span class="StaticMenuItemStyle" style="display:block;"
onmouseover="style.backgroundColor='#0088CB';style.color=white;"
onmouseout="style.backgroundColor='';"
style="color:Color [Blue];width:180px;">
Services
<br />
<div style="background-color: Blue; width: 180px;height: 5px;"></div>
</span>
</a> </li>
Mention the jquery is initialize before the script