Usually my page is defined as :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it">
but using a Facebook Plugin, it says :
Add an XML namespace to the <html> tag of your document. This is necessary for XFBML to work in earlier versions of Internet Explorer.
<html xmlns:fb="http://ogp.me/ns/fb#">
So I wrote :
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://ogp.me/ns/fb#" xml:lang="it">
Is this correct? Or html document need only 1 xmlns?
As long as you do not specify the DTD as XHTML Strict, multiple xmlns attributes are allowed. So it's ok.
As you're using XHTML 1.1 it shouldn't cause any problems: http://www.w3.org/TR/xhtml11/conformance.html
Related
I'm new to XHTML and I keep getting this error and can't find the solution anywhere.
Here's the error:
error.png
Here's my code:
<!DOCTYPE html public "-//project//test.xhtml">
<html>
<head>
<title>Tools</title>
<link href="oof.css" rel="stylesheet"type="text/css">
</head>
<body>
<div class="page">
<!DOCTYPE html public "-//project//test.xhtml"> is not an XHTML Doctype.
The specific error you get is because an identifier has to be PUBLIC or SYSTEM and it is case sensitive.
The Doctype needs to reference the DTD you are validating against, not an XHTML document.
Most XHTML documents will use this Doctype:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
However, there is little point in using XHTML 1.0 in 2018. You would probably be better off using HTML 5 instead.
If you are using the XML serialisation of HTML 5, then you wouldn't use a Doctype at all.
Most people don't get any benefit from using XML though, and would be better off writing HTML instead. That uses the Doctype:
<!DOCTYPE html>
… and then only for historical reasons to trigger Standards mode in browsers.
You have a lot of errors in your syntax.
LINK tag is a self closing tag.
DOCTYPE html public "...." defines some info. Read about it here
Every opening tag has a closing tag
Here's what it should look like
<!DOCTYPE html public "-//project//test.xhtml">
<html>
<head>
<title>Tools</title>
<link href="oof.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="page"></div>
</body>
</html>
So, I wanted to be strict on me and took one of HTML5 pages and validated it as XHTML Strict -- all the way.
Fixed every error reading the very helpful error messages. Now the entire page is fully XHTML compliant. But the page shows only the DIVS containing the ads. The main DIV containing the page matter is gone, haha!
Here's the page for your enjoyment:
http://mypollingcenter.com/charts1.htm
Well, I apologize. The problem was that in my over-zealousness, I changed
this line:
<script src="../avazyabadu/kramaanukrama.js" type="text/javascript"></script>
to this:
<script src="../avazyabadu/kramaanukrama.js" type="text/javascript"/>
Empty tag/element rule, you know.
So, the validator took the whole thing as JavaScript, maybe?
Lessons I learned:
That JavaScript external file reference is an exception to the XHTML/XML rule. Keep the closing tag.
The “space before slash” rule is no more with XHTML.
Mark up fully compliant with strict XHTML validate as HTML5, provided you switch headings as below.
XHTML does not need character set declaration if your page is in UTF-8
Use this Validator (Not this one)
XHTML top lines:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
HTML top lines:
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
i use the facebook and twitter plugins in my html 4.01 strict doctype,which give me the following error.
Error Line 166, Column 23: there is no attribute "HREF"
Line 166, Column 107: there is no attribute "SHOW_FACES"
please help me how i removed these validation error's from my html page.
i use the following doctype and code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
facebook code
<fb:like-box href="http://www.facebook.com/pages/mysite/45662125588" width="692" show_faces="true" stream="true" header="true"></fb:like-box>
please help me if you have any suggestion
Try this:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:og="http://ogp.me/ns#"
xmlns:fb="http://www.facebook.com/2008/fbml"
xmlns:google="http://base.google.com/ns/1.0"
xmlns:twitter="http://api.twitter.com/">
Then if that doesn't work, change the DOC type to something like this
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML+RDFa 1.0//EN"
"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
Currently, it seems that the only way for validator + facebook plugin to work is to use
HTML5 doctype
<!doctype html>
I'm using this dtd
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
Error is for this attribute?
<html lang="en">
Should i remove this from DTD?
Just use <doctype html>. You're not using XML anyway, and the xml:lang attribute doesn't do anything in HTML.
I think this is it:
A. Changes from XHTML 1.0 Strict
1. On every element, the lang attribute has been removed in favor of the xml:lang attribute (as defined in [XHTMLMOD]).
We often see <!DOCTYPE ...> as follows:
<!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">
What's the functionality of !DOCTYPE?
The most significant use of DOCTYPE is to switch a browser between Quirks Mode and Standards Mode rendering.
This functionality came about because of the "broken" rendering in old versions of IE. It was realised that if Microsoft just "fixed" the IE rendering engine lots of existing sites would not render properly. So the way it works is if you put any valid DOCTYPE declaration at all in your page the assumption is that you know what you're doing and your browser will render in a standards compliant way, and if you don't put one in it will render in the old "wrong" way.
This was originally done in IE for the Mac, but this behaviour is the same in all versions of IE since IE5, and Firefox, Chrome, Safari and Opera.
What the DOCTYPE is supposed to be is a Document Type Definition. HTML is subset of SGML (as is XML). The DTD tells a parser which syntax you are using. So in a webpage your DOCTYPE should match the version of HTML you are using.
It tells to the validator which version of HTML do are you using. A browser use this information to render the page correctly.
Here are correct version of DOCTYPE:
HTML 4.01 Strict, Transitional, Frameset
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML 1.0 Strict, Transitional, Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
XHTML 1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
HTML5
<!DOCTYPE html>
Mainly for compatibility.
Modern browsers don't need it anymore. See this HTML file that does not have a !DOCTYPE:
<p>hello</p>
The browser automatically inserts the !DOCTYPE.
But that's only in modern browsers.
In IE8, some css properties only have functionality when the doctype is stated.
So, if you don't need to support ancient relic browsers, you don't need it. But it has become a programmer custom!
———
Update:
The doctype used to require a DTD URL. The DTD defines all the elements in the document. If you are using the HTML 4.01 DTD, HTML 5 elements will not work.
But it is not all sunshine and butterflies.
Some features will break. Without a DOCTYPE, the green square fills up 50% of the width:
div {
width:50%;
background-color:#00ff00;
}
<div>div</div>
But with one:
div {
width:50%;
background-color:#00ff00;
}
<!DOCTYPE html>
<div></div>
However, stack snippets automatically adds a !DOCTYPE, so you can't see it here.
It tells your browser which version of HTML it is loading making the load time a bit quicker as the browser know what to expect.
The doctype is a standard defined by the w3c - when you hear about standards based web development this is what they are talking about. The idea of using the doctype is you create valid HTML that follows the doctype.
If you are clever you can actually write your own doctype.
The main (practical) purpose of DOCTYPEs is to force IE from "quirks mode" to "standards-compliant mode", both euphemisms for "horribly broken mode" and "slightly broken mode" (respectively).
In other browsers, the page responds normally without the !DOCTYPE, with these exceptions:
try using the z-index CSS property in Internet Explorer. In quirks mode, it does not work. You need to be in standards-compliant mode for it to work. The easiest way to do this, of course, is with a DOCTYPE.
Browsers behave differently with and without a !DOCTYPE. Here's the code:
<div>some text</div>
<style type="text/css">
div {
background-color:#00ffff;
height:10%;
width:10%;
}
</style>
This web page renders differently when it has a !DOCTYPE and when it does not.
Without a DOCTYPE:
With a DOCTYPE:
Without a !DOCTYPE, the element is sized according to CSS. But with the !DOCTYPE, it is sized according to the element.
The !doctype was not that simple back then. You had to specify a DTD URL:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
The DTD looks something like this:
<!ENTITY % HTML.Version "-//W3C//DTD HTML YOURVERSION Transitional//EN"
-- this is a comment.
-->
<!ENTITY % HTML.Frameset "IGNORE">
<!ENTITY % ContentType "CDATA"
-- media type, as per [RFC2045]
-->
<!ENTITY % ContentTypes "CDATA"
-- comma-separated list of media types, as per [RFC2045]
-->
<!ENTITY % Charset "CDATA"
-- a character encoding, as per [RFC2045]
-->
<!ENTITY % Charsets "CDATA"
-- a space-separated list of character encodings, as per [RFC2045]
-->
<!ENTITY % LanguageCode "NAME"
-- a language code, as per [RFC1766]
-->
<!ENTITY % Character "CDATA"
-- a single character from [ISO10646]
-->
<!ENTITY % LinkTypes "CDATA"
-- space-separated list of link types
-->
<!ENTITY % MediaDesc "CDATA"
-- single or comma-separated list of media descriptors
-->
<!ENTITY % URI "CDATA"
-- a Uniform Resource Identifier,
see [URI]
-->
<!ENTITY % Datetime "CDATA" -- date and time information. ISO date format -->
<!ENTITY % Script "CDATA" -- script expression -->
and so on an so forth.