How to insert XUL into a XHTML document - html

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)

Related

message element meta is not allowed here in PHPStorm

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>

What's the difference between "//W3C//DTD HTML 4.01" and "//W3C//DTD XHTML 1.0"?

Hi all:
I want to get the autual height of the web browser,but I got some confusions about the W3C DTD HTML 4.01 and //W3C//DTC XHTML 1.0,below is my issue detail:
If I am using W3C DTD HTML 4.01 at the top of the page header and use document.body.clientHeight,then I can not get the full height of the browser:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test jQuery Height</title>
<script type="text/javascript" src="../lib/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
var height=document.body.clientHeight;
alert(height);
})
</script>
</head>
<body>
<div style="margin-left:30px;">
<button>Start Select</button>
<button>Stop Select7lt;/button>
</div>
</body>
</html>
But if I change to //W3C//DTD HTML 4.01 or use document.documentElement.clientHeight,then I could get the actual height of the browser:
1. Using //W3C//DTD HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test jQuery Height</title>
<script type="text/javascript" src="../lib/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function(){
var height=document.body.clientHeight;
alert(height);
})
</script>
</head>
<body>
<div style="margin-left:30px;">
<button>Start Select</button>
<button>Stop Select7lt;/button>
</div>
</body>
</html>
Using document.documentElement.clientHeight
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test jQuery Height</title>
<script type="text/javascript" src="../lib/jquery-1.8.3.min.js">
</script>
<script type="text/javascript">
$(function(){
var height=document.documentElement.clientHeight;
alert(height);
})
</script>
</head>
<body>
<div style="margin-left:30px;">
<button>Start Select</button>
<button>Stop Select7lt;/button>
</div>
</body>
</html>
So,my question is What's the difference between "//W3C//DTD HTML 4.01" and "//W3C//DTD XHTML 1.0"?
Any help will be grateful!
The difference between “//W3C//DTD HTML 4.01” and “//W3C//DTD XHTML 1.0” is that the former has “HTML 4.01” as opposite to “XHTML 1.0” in the latter.
What you have actually observed is the difference between the two document type declarations
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
The former puts browsers to “standards mode”, whereas the latter puts them to “quirks mode”. In quirks mode, strange things may and will happen. This may include nonstandard calculation of widths and heights.
Unless this is about a legacy page that relies on quirks mode, you should use “standards mode” and use CSS and DOM by the specifications.
The HTML 4.01 strict doc type i.e "-//W3C//DTD HTML 4.01//" , validates against the HTML 4.01 spec, although it doesn't allow any presentation markup or deprecated elements (such as font elements) or framesets to be used. It validates loose HTML style markup, such as minimized attributes and non-quoted attributes (eg required, rather than required="required")
The HTML 4.01 transitional doc type i.e "-//W3C//DTD HTML 4.01 Transitional//EN" validates against the HTML 4.01 spec. It allows some presentation markup and deprecated elements (such as font elements) but not framesets. Again, it validates loose HTML style markup
These are the exact XHTML 1.0 equivalents of the HTML 4.01 doctypes i.e "-//W3C//DTD XHTML 1.0 Transitional//EN" or "-//W3C//DTD XHTML 1.0 Strict//EN" we discussed above, so functionally they are the same, except that they won't validate loose HTML style markup: it all needs to be well formed XML.
Here is a good comparison of these two document standards: http://www.w3.org/TR/xhtml1/diffs.html
In short: with XHTML you have to follow the XML structure, just as with any other XML document. HTML4 Transitional is more flexible and allows e.g. usage of additional attributes in tags or skipping of some attributes.
EDIT:
document.documentElement seems to work in IE standard mode
document.body in IE quirks mode and all other browsers I usually use.
document.body is more of a standard than the other one. But it does not relate to the (X)HTML standard.

unicode gibberish character in html

I am trying to rewrite old php mysql website in codeigniter, The site is in unicode, and text in database is stored like this
बेलायतम&.
when i pull data from database and display in html it appears like this
सरà¥à¤µà¥‹à¤šà¥à¤šà¤•à¥‹ à
It is fine in old site, I am using exactly as same header as old site in html
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I am banging my head how to correct text ?
Try this
<meta charset='utf-8'>
There should be a problem, html's codes you are using are right, just in case check if you can see proper characters on this website:
http://www.unicodeblocks.com/block/Devanagari
and make sure you are using:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Please double check it - use "view page source" on your page and check, maybe you used meta tag twice with different variables?
and one more...
if you are using db, please do this:
$mysqli->query('set character set utf8');

Correct doctype, attributes, encoding for Chinese language

How should I modify this in order to display Chinese characters?
Those question marks are actually Chinese writings.
Thanks
<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
?????????????????????????????
????????????????
?????????????????????,?????????????,???!
</body>
</html>
I would making sure that your editor's character encoding settings match. (i.e. change the setting to UTF-8 and try retyping/repasting). For example, in Eclipse, IIRC, the default encoding for most files is dependent on your regional settings (it will usually pick a non-UTF variant such as ISO-8859-1 (Latin-1) - on my machine). Which editor are you using?

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>