I am trying to create a responsive design layout using XML that relies on setting the initial-scale
of the user agent. In HTML I would use some variation of the <meta viewport>
tag such as this:
<meta name="viewport" content="width=320, initial-scale=1">
however the lack of a closing tag is a problem for XML.
Is there a way for me to do this in valid XML that would also work in browsers?
Startec
Given this answer (which is specifically about closing the <meta>
tag) I think the simplest thing to do here would be to just close the meta element with />
as browsers will not complain.
Paul Sweatte
Use the XHTML namespace:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="viewport" content="width=320, initial-scale=1"/>
</head>
<body>
<!-- Insert your content here -->
</body>
</html>
OR:
<html:meta xmlns:html="http://www.w3.org/1999/xhtml" name="viewport" content="width=320, initial-scale=1"/>
References
来源:https://stackoverflow.com/questions/29979092/how-to-use-meta-viewport-in-xml