应如何<!DOCTYPE>部分看在JSF? HTML5或XHTML? [英] How should a <!DOCTYPE> section look in JSF? HTML5 or XHTML?

查看:168
本文介绍了应如何<!DOCTYPE>部分看在JSF? HTML5或XHTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这只是我有现在一个好奇心。在Eclipse中,这是< HEAD> 上附带一个的新的facelet模板的为例,但在大多数模板是一回事定义的部分

It's just a curiosity I'm having right now. In Eclipse this is the <head> section that came defined on a New Facelet Template for instance, but for the most template is the same thing :

<!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"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
  ..
</head>

我想用户更多的明确的$ C $就可以了C,所以我更改为:

I would like to user a more clear code on it, so I change to :

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets">
<head>
  ..
</head>

它工作在发展很好,但我不知道是否这种做法将在未来给予任何问题,通过许多浏览器或设备(手机)。

It works fine in development, but I was wondering if this kind of approach would give any problem in the future, through the many browsers or device (mobile).

推荐答案

这就是HTML5的doctype,它应该在所有的浏览器,包括IE6工作得很好。

That's the HTML5 doctype and it should work just fine in all browsers, including IE6.

JSF正式指定生产XHTML 1.0兼容的标记(与这里和<一个HREF =htt​​p://java.net/jira/browse/JAVASERVERFACES-1450相对=nofollow>有中只有少数的侵犯,其中被固定在JSF的2.2和/或实现是通过上下文管理PARAMS)。 JSF可以通过设计不会产生非XML sytnax(如&LT; BR&GT; 而不是&LT; BR /&GT; ),因此旧的HTML4 DOCTYPE是没有办法用JSF生产HTML输出兼容(也就是,当你尊重标准和/或恐惧的 W3验证;但是,大多数如果不是所有的浏览器都非常宽容的就可以了)。在相反老HTML4 DOCTYPE,HTML5的DOCTYPE允许XML语法,因此与XHTML文档类型兼容。 JSF页面,因此可以用HTML5的doctype创作。

JSF is officially specified to produce XHTML 1.0 compliant markup (with here and there only a few violations in the implementations which is fixed in JSF 2.2 and/or are manageable by context params). JSF can by design not produce non-XML sytnax (e.g. <br> instead of <br/>) and therefore the old HTML4 doctype is in no way compatible with JSF-produced HTML output (that is, when you respect the standards and/or fear the W3 validator; however, most if not all browsers are very forgiving on it). In contrary to the old HTML4 doctype, the HTML5 doctype allows XML syntax and is therefore compatible with XHTML doctypes. JSF pages can therefore be authored with HTML5 doctype.

的文档类型是唯一重要的关于如何web浏览器间$ P $点和presents HTML标记(如由JSF在特定的情况下产生的,而是在HTML不一定需要由JSF和由此产生浏览器的presentation在技术上是完全无关的JSF)。 Escpecially微软IE具有一定的文档类型或完全缺乏的文档类型的一个主要问题。 在这个页面的底部你可以找到的浏览器行为的简要概述与某些文档类型组合。有三个标准的行为:

The doctype is only of importance for how the webbrowser interprets and presents the HTML markup (as produced by JSF in your specific case, but the HTML does not necessarily need to be produced by JSF and thus browser's presentation is technically completely unrelated to JSF). Escpecially Microsoft IE has a major problem with certain doctypes or a complete lack of doctype. At the bottom of this page you can find a concise overview of browser behaviour in combination with certain doctypes. There are three standard behaviours:


  • 问: - 怪异模式。你真的不希望有。它会触发IE中盒模型错误。 CSS的宽度高度然后错误地覆盖填充边框

  • 系统 - 几乎标准模式。价格实惠,表格单元格只有垂直尺寸不按CSS2规范。如果你想避免图像的神秘空白表格单元格有用。

  • 的S - 标准模式。浏览器尝试完全W3 HTML / CSS符合标准。 preferred模式,因为它是你可以少跌多肯定,你的网站看起来完全一样在所有浏览器的唯一方式。

  • Q - Quirksmode. You really don't want to have that. It triggers box model bug in IE. The CSS width and height then incorrectly covers the padding and border.
  • A - Almost standards mode. Affordable, only vertical sizing of table cells is not as per CSS2 spec. Useful if you want to avoid mysterious gaps of images in table cells.
  • S - Standards mode. Browser tries to be fully w3 HTML/CSS standard compliant. Preferred mode since it's the only mode you can be less or more certain that your website will look exactly the same in all browsers.

在你的具体情况,从XHTML 1.0过渡的doctype到HTML5的doctype,火狐,Chrome,Safari和改变IE> = 8从A到S去了。所以,你一定要检查你的网站的浏览器的presentation为表单元格的图像填充,如果你打算一个像素完美的设计。

In your particular case, with the change from XHTML 1.0 transitional doctype to HTML5 doctype, Firefox, Chrome, Safari and IE>=8 will go from "A" to "S". So, you should definitely review the browser's presentation of your website as to padding of images in table cells if you intend a pixel-perfect design.

至于在IE中DOCTYPE的重要性,这里是一片的HTML这表明在IE6-9Q引发了框模型错误(注意,这并不体现在IE10了):

As to the importance of the doctype in IE, here's a piece of HTML which demonstrates the box model bug triggered by "Q" in IE6-9 (note that this does not manifest in IE10 anymore):

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Remove DOCTYPE to trigger quirksmode</title>
        <style>
            #box { 
                background: yellow; 
                width: 100px;
                padding: 20px; 
                border: 20px solid black; 
                margin: 20px;
            }
        </style>
    </head>
    <body>
        <div id="box">box</div>
    </body>
</html>

Copy'n'paste'n'run它。随着&LT;!DOCTYPE HTML&GT; present,你会看到一个矩形。如果没有DOCTYPE行,你会看到一个真正的平方(以IE10您在webdeveloper工具集(preSS F12)需要改变浏览器模式例如IE9才能看到它)。

Copy'n'paste'n'run it. With <!DOCTYPE html> present, you'll see a rectangle. Without the doctype line you'll see a genuine square (in IE10 you need in the webdeveloper toolset (press F12) to change the "Browser mode" to e.g. IE9 in order to see it).

  • JavaServer Faces 2.2 and HTML5 support, why is XHTML still being used
  • Is it possible to use JSF+Facelets with HTML 4/5?
  • Should I start with HTML or XHTML?

这篇关于应如何&LT;!DOCTYPE&GT;部分看在JSF? HTML5或XHTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆