message element meta is not allowed here in PHPStorm - html

Can someone explain me why I'm not allowed to use the <meta>-tag?
I always use it to ensure utf-8 encoding.
My code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8">
My IDE (PHPStorm) throws the following message:
Element meta is not allowed here

Put the meta tag inside the head, the only children of the HTML element should be head and body.

Try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8">
</head>
</html>

Related

iframe. Display another html page in it; whats the simplest implementation?

Heres what I tried...
In Main html page....
<iframe src="./example.html" id="frame" frameborder="1"></iframe>
and example.html looks like this..
<!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">
<head>
<title>Example</title>
</head>
<body>
<p>YOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO</p>
</body>
This results in empty iframe.
--UPDATE--
Ok,the problem was that simply refreshing the page did not update the iframe. but when I clsed it and reopened it it was fine. Can someone explain this? Do iframes need to be refreshed?
Example.html should be:
<!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">
<head>
<title>Example</title>
</head>
<body>
<p>YOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO</p>
</body>
</html>
Also make sure your path to example.html is correct in your iframe, as well as having a set height & width.

validate html, problem in my doctype and use of lan(g)

I can't get my website validated; it jumps an error on my doctype which is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//ES" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
(under Spanish)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
(under English)...
The html tag:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lan="en">
THE ERROR
Error: unrecognized DOCTYPE; unable to check document
any idea why?
do not specify the language in the doctype but always use:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" .......
Set the language in the <html> tag: <html lang="es">
http://www.w3.org/QA/2002/04/valid-dtd-list.html#DTD
http://www.alistapart.com/articles/doctype/
I use this one, which is the same, except for the html in lowercase. I'm not sure if that would matter.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Dit you check if there's any whitespace before the doctype?
The upper/lower case issue of "html" is described here: Recommended Doctype Declarations

writing HTML back to file

Header for my input file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
After doing certain changes in document using lxml.html parser, i need to save the changes in a file. while doing so Header of the file changes to:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="UTF-8"??>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" xml:lang="en">
i am not sure why is this happening, may be its too silly but i am stuck here. please help!!
Maybe parser caters to the IE6's Quirks mode triggering?

W3C Validator - Document type does not allow element "body" here

I am trying to validate the following code with the W3C validator:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Test</title>
</head>
<body>
</body>
</html>
I get two errors:
Document type does not allow element "body" here
End tag for "html" which is not finished
Does anyone know how to fix this?
You're using the Frameset DTD, which doesn't allow body. It is meant for use with framesets, which are used to display frames. You can use Strict instead:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Test</title>
</head>
<body>
</body>
</html>

How to insert XUL into a XHTML document

I have a XHTML document and want to embed XUL widgets into the document. What is the correct XML syntax to do so?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
insert XUL here
</body>
</html>
add xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" to your <html> tag.
then use <xul:element>, e.g. <xul:vbox>
Edit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<xul:vbox>
</xul:vbox>
</body>
</html>
Also, I assume this isn't such a simple case... otherwise there wouldn't be much point in wrapping the xul in html (though the other way around does happen sometimes)
Edit
Some additional points to keep in mind when doing this:
must be served with a valid xml type. e.g. application/xml or text/xml -- not text/html. (See https://bugzilla.mozilla.org/show_bug.cgi?id=101147#c12 -- the whole thread is worth a read)
must be valid xml. A certain degree of sloppiness is tolerated by browsers when parsing html (unclosed tags, etc.) and this is not that case for a document containing xul (even the html parts of the document)
(thanks to Nikolay for the first point)