HTML5 valid namespace tag prefixes - html

When validating my page, the W3-Validator gives me an error for every
<tag addthis:title="AddThis share title" />
attribute in my code. How can I make those attributes valid for HTML5, so the page validates? I need those tags so addthis uses the correct titles for my sharing links, so I can't get rid of them...

I'd have to assume that "addthis" is an XML namespace; does the html tag declare something like <html xmlns:addthis="..">? If not, it won't validate because the namespace is undefined for the document. If so, it won't validate because "addthis" isn't a standard namespace.
See: http://www.w3.org/TR/2011/WD-html5-20110405/namespaces.html
Confounded to your troubles is the fact that "the HTML syntax does not support namespace declarations, even in foreign elements."
Check out http://www.w3.org/TR/2011/WD-html5-20110405/syntax.html#elements-0 , the cdr:license example.
Unfortunately (in your case) HTML5 isn't XML, so XML namespaces aren't necessarily valid in HTML5. Your only real option is to ignore the validation error.
Not unrelated question: HTML5 validator failing on Facebook OpenGraph XML Namespace xmlns:og
Oh, and while you're there, the <tag /> syntax is also XML, not HTML5.

You can't make them valid. Not in HTML, not in XHTML. The only valid custom attributes allowed in HTML5 start "data-".
You could make your markup valid HTML5+something or XHTML5+something, but getting a validator to check for that is a non-trivial task.

Related

W3C validation error: "Bad value X-XRDS-Location for attribute http-equiv on element meta"

I am getting the above validation error in response to the following line in my HTML:
<meta http-equiv="X-XRDS-Location" content="http://www.example.com/wp-content/plugins/socialauth-wp/hybridauth/index.php?get=openid_xrds" />
I use WordPress social auth plugin, that automatically adds this line to the head of every page.
I am not sure what this line does to the site but it throws a validation error.
What does the meta line does to the site, is it mandatory?
I gone through the question
Get rid of “Bad value X-XRDS-Location for attribute http-equiv on XHTML element meta.” in XHTML5 validation, but I'm not sure how to register it.
My answer to the linked question applies here, too:
If you use HTML5, you may only use the following values for the http-equiv attribute:
those defined in the HTML5 spec, or
those registered in the WHATWG wiki page "PragmaExtensions".
X-XRDS-Location is not defined/registered, so HTML5 doesn’t allow to use it.
What does the meta line does to the site, is it mandatory?
I guess the linked XRDS document is used to discover your OpenID service provider. Or for Oauth, etc..
An alternative may be to send the HTTP header X-XRDS-Location. If you send it, you could remove the meta element (unless some data consumers only look for the occurence in the HTML, which would be a bad practice).

One W3C validation errors I really want to correct

This would be my first website and I do not want to leave it these errors. Can someone please help me with these ones?
Error 1:
if (xmlhttp.readyState==4 && xmlhttp.status==200)
error: character "&" is the first character of a delimiter but occurred as data.
WHEN i &, then my AJAX code stops working
I have no clue how to correct this one.
Error 2:
…ems"><a href="brushdescription.php?id=<?php echo $popularbrushesrow['bd_brushi…
error: character "<" is the first character of a delimiter but occurred as data
Again the same error but for < this time
UPDATE:
I am using this doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< and & are some of the predefined entities in XML, which need escaping when validating the page as XML or XHTML.
< should be replaced with < (less than)
& should be replaced with & (ampersand)
However, if using these characters in JavaScript you can (instead) enclose the script in a <![CDATA[]]> section, which instructs the parser to not interpret the code as markup and will also not result in a validation error.
Try wrapping your Javascript with <![CDATA[]]> tags like so:
<script>
//<![CDATA[
// Javascript goes here.
//]]>
</script>
Also, you should look into separation of concerns. Try to move your logic out of you view. If your Javascript is in your HTML page, try to include it from a separate file.
From Wikipedia:
HyperText Markup Language (HTML), Cascading Style Sheets (CSS), and JavaScript (JS) are complementary languages used in the development of webpages and websites. HTML is mainly used for organization of webpage content, CSS is used for definition of content presentation style, and JS defines how the content interacts and behaves with the user. Historically, this was not the case though. Prior to the introduction of CSS, HTML performed both duties of defining semantics and style.
Use HTML, not XHTML (or, if you insist on using XHTML, see the guidelines on how to write XHTML that can be parsed as HTML).
I can't see how you could have generated that error. Some more context would be useful.
For the first error, consider switching from XHTML to HTML5. There's really little reason to use XHTML. Use this:
<!DOCTYPE html>
The W3C validator is for client-side code, but it seems you are trying to validate server-side code, hence the PHP tag. Send the rendered code for validation and the second error will go away. The rendered code is the one visible in the browser under "View source". You can supply the URL if it's already online somewhere.
By XML rules, “The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings " & " and " < " respectively.” So “&&” is to be written as &&.
However, this is such works only when the document is processed as “real XHTML” due to having been sent with an XML content type, e.g. with the HTTP header Content-Type: application/xhtml+xml. Doing so implies that old versions of IE will choke on it and modern browsers will refuse to render the document at all if it contains any well-formedness error. People don’t normally do that – they just use XHTML because someone told them to do so, and their documents are sent with an HTML document type, which means among other things that script element content is processed differently. This explains why a fix that satisfies the validator makes the page break.
In the XHTML 1.0 specification, the (in)famous appendix C says: “Use external scripts if your script uses < or & or ]]> or --.” This is the simple cure if you need to use XHTML. Just put your script in an external file and “call” it with <script src="foo.js"></script>.

Knockout.js data-bind attribute causes html validation warning

I'm using the HTML Validator firefox add-on and when I go to the home page of http://knockoutjs.com/, I get warnings about the data-bind attribute (for the Live Example):
Examples:
<select> proprietary attribute "data-bind"
<button> proprietary attribute "data-bind"
I also get errors regarding the data-bind attribute when submitting the URL at http://validator.w3.org/.
I know this html attribute is used by knockout.js to do some data binding, but can we conclude that this approach does not follow the HTML specification? Does knockout.js follow the spirit of valid HTML markup?
They are HTML 5 custom attributes. Try to validate against HTML 5 specs and you should get an ok on the validation.
But since long you have been able to use custom attributes as you see fit although it may have violated strict HTML 4 specs.

embed issue in html validataion

When i validating my site i got following issue
<embed src="banner.swf" quality="high" pluginspage="http://www.macromedia…
✉
You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).
This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.
How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute. If you received this error when using the element to incorporate flash media in a Web page, see the FAQ item on valid flash.
How Can i solve this???
<embed> is deprecated, you should use <object> instead.
See http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3
embed isn't part of the HTML 4.0 or XHTML 1.0 specification (although it is part of HTML5). The object tag is the standardized tag to embed Flash and similar content in a webpage.

Help with putting RDF in a web page (jsp)

When I read the documentation on Common-Tags, I thought it would be easy to put this in a jsp because the examples were cut and paste
<body xmlns:ctag="http://commontag.org/ns#" rel="ctag:tagged">
<span typeof="ctag:Tag"
rel="ctag:means"
resource="http://rdf.freebase.com/ns/en.u2"
property="ctag:label" content="U2"/>
</span>
</body>
It's a good thing that we're using Eclipse in our dev work. It's telling us that something is wrong with our markup. It's underlining the common-tags markup with yellow returning:
Undefined attribute name
What am I missing here? or is this completely okay?
The typeof, resource and property attributes are extensions to XHTML which are part of the RDFa specification which is why Eclipse doesn't know about them.
Since RDFa+XHTML is now a W3C recommendation this is absolutely fine to use as is.
http://www.w3.org/TR/rdfa-syntax/#rdfa-attributes
I assume you're not sending your pages with an XML MIME type, because that snippet isn't well-formed. Using RDFa isn't allowed when using a text/html MIME type. For an alternative, have a look at "microdata".