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".
Related
I am using the w3 include for my footer on each page. The pages loads fine and everything works great except when I run the code through https://validator.w3.org/ for validation I am getting this error:
"Error: Attribute w3-include-html not allowed on element div at this point."
<!--FOOTER-->
<div w3-include-html="../includes/footer.html"></div>
<!--Include HTML Files-->
<script>
w3.includeHTML();
</script>
Is the w3 include not widely supported? Should I be doing this with PHP or asp.net? or ajax?
You are probably using a script offered by w3schools.com. Note that w3schools has nothing to do with W3C. It’s just a custom JavaScript that makes use of an invalid attribute which likely gets replaced after the JS got executed.
The W3C HTML validator doesn’t execute JavaScript, so it doesn’t see the document after the JS replaced the attribute.
Possible solutions:
If you want to validate your HTML after the JavaScript got executed, you could open your page in a browser, mark everything, open the source code for the selection, and copy-paste this markup into the W3C validator.
If you just want to have a valid document before/without executing the JavaScript, you could change the script to use a data-* attribute, e.g., data-include-html.
If you want to support users and bots/services that don’t execute JavaScript, you shouldn’t rely on JavaScript. Using a server-side programming language (like PHP) could help here, but (depending on your use case) you could also just generate plain static HTML files, e.g., with the help of a static site generator.
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.
There's some way to cut the html tags with self-closing slash like <br/> and transform it to <br> so you can view on the source view the code without the slash?
Some DOM Jquery implementation?
I'm working on .NET if this can be help as a tip.
This is the real problem: NET-enabling start-tag requires SHORTTAG YES
In your other question, DaveB's answer points to a browser capabilities file. In that file the tagWriter is set toSystem.Web.UI.HtmlTextWriter.
I haven't tested this, but you may be able to sub-class System.Web.UI.HtmlTextWriter and initialse the value of the SelfClosingTagEnd field so that its value is > instead of />.
Put the name of the new class in the tagWriter setting of your browser capabilities file and try that.
this <div id="adiv"></div> will in JSPX somehow be translated into <div id="adiv" />. The way I got it to work is to add empty comments inside like <div id="adiv"><!-- --></div>. I dont understand why this is happening and is there a better to solve this issue?
That's by JSP specification:
JSP.6.2.3 Semantic Model
...
To clearly explain the processing of whitespace, we follow the structure of the
XSLT specification. The first step in processing a JSP document is to identify the
nodes of the document. Then, all textual nodes that have only white space are
dropped from the document; the only exception are nodes in a jsp:text element,
which are kept verbatim. The resulting nodes are interpreted as described in the
following sections. Template data is either passed directly to the response or it is
mediated through (standard or custom) actions.
In theory, it should not harm if you use a XHTML doctype to present the document in the client side instead of a HTML doctype. However, even the XHTML spec requires some elements to be not self-closing. Another workaround would be using <jsp:text /> instead of a comment.
<div id="adiv"><jsp:text /></div>
JSP(X) is however an old view technology. Its successor, Facelets, does a better job in this.
See also:
JSP Document/JSPX: what determines how tabs/space/linebreaks are removed in the output?
Why don't self-closing script tags work?
I am trying to validate a page in which I have implemented Lightbox and W3C thinks rel="lightbox['gallery']" is invalid code. Code is :
<a rel="lightbox[gallery]" href="link-to-image">
...image...
</a>
Error:
Bad value lightbox[gallery] for attribute rel on element a: Keyword lightbox[gallery] is not registered.
Any insight into this is welcomed.
At least for me it's more comfortable to use "target" instead of "rel" or "data-rel" (which is not a standard link attribute anyway), thus still pass w3 HTML5 validation and do not mess with page's CSS setup ("class" is commonly used for layout and such). Of course all "*.getAttribute('rel')" in javascript source has to be updated accordingly.
You're trying to validate HTML5, right?
It's simple enough I'm afraid; whereas HTML4 allows pretty much any content in rel, HTML5 is much stricter and "lightbox[gallery]" isn't a registered rel type.
I've seen a fix which should work: get Lightbox to look for class="lightbox[gallery]" instead of rel="lightbox[gallery]", but so far my inept tweaks haven't worked. I'm trying to contact the Lightbox dev to ask him about this, but his forum is giving 500 errors. Not a good sign. :(
Or a better idea - in my opinion ofc - instead of rel use data-rel. But also you have to modify lightbox a little bit ;-)
With Lightbox2, you should use
<strong><a data-lightbox="lightbox[gallery]" href="link-to-image"></strong>
instead of
<strong><a rel="lightbox[gallery]" href="link-to-image"></strong>
This will validate as HTML5.