保持 CSS 100% 验证有什么实际好处?
对于客户的项目来说,保持 CSS 100% 验证(不使用任何 hack)有什么实际好处?即使没有跨浏览器问题。
如果我不能 100% 保持 CSS 有效性,我将来会面临什么类型的问题。
What is the practical benefit to keep CSS 100% validated (not using any hacks), for client's projects.? even if there is no cross browser problem.
And what type of problem i can face in future if i do not maintain CSS validity 100%.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
实用......嗯,我想你可以对客户说“它 100% 经过验证”?在实践中,如果您正在做任何复杂的事情(例如,不透明度),那么维护 100% 有效的 CSS 极其 非常困难,条件样式表是消除大多数此类情况的一种方法,但不是全部。
在这种情况下,执行有效的操作,而不是验证器告诉您的操作。话虽如此,不要忽略那些不是出于特定原因而存在的合法错误的验证错误。
Practical....hmm, I suppose that you can say to the client "it's 100% validated"? In practice if you're doing anything complex (e,g, opacity) it's extremely difficult to maintain 100% valid CSS, conditional stylesheets it a way to eliminate most of these cases, but not everything.
Do what works in this case, not what the validator tells you. That being said, don't ignore validation errors that are legitimate errors not there for a specific reason.
页面在当前版本的浏览器中看起来正确的事实并不能保证它在未来版本中也是正确的。
如果您使用无效的 CSS,您可能会无意中依赖渲染代码中的错误,如果修复该错误,可能会破坏您的布局。
但是,如果您使用有效的 CSS,则任何符合标准的浏览器都应该正确显示页面,只要它遵循该版本的 CSS 标准即可。
The fact that a page looks correct with a current version of a browser doesn't guarantee that it will in a future version.
If you use non-valid CSS, you might be inadvertently relying on a bug in the rendering code, which, if it gets patched, could break your layout.
If you use valid CSS, however, any standards-compliant browser should display the page correctly, as long as it follows implements that version of the CSS standard.
简而言之。如果验证器抱怨供应商特定/css3 属性(例如
-webkit-border-radius
),请忽略它。还有什么你应该修复的。In short. If the validator complains about vendor specific/css3 properties like
-webkit-border-radius
ignore it. Anything else you should fix.保持 CSS 100% 验证的实际好处还在于您可以更轻松、更快地检测代码中的错误。
例如,在网站开发过程中,我总是使用浏览器,它可以清楚地显示 XHTML 或 CSS 何时无效(绿色/红色图标)。它节省了我几个小时的时间:有时,如果我使用非常基本的编辑器,如果我在 CSS 代码中拼错了某些内容,当我在浏览器中看到 CSS 不再有效时,我会立即注意到。
注意:拥有 100% XHTML 也有很大帮助。有时,无效的 XHTML 是由隐藏代码中的错误引起的。
The practical benefit to keep CSS 100% validated is also the fact that you can detect easier and much faster a mistake in your code.
For example, during website development, I always use a browser which shows me clearly when XHTML or CSS are invalid (green/red icons). It saved me a few hours of my life: sometimes, if I work with very basic editor, if I misspell something in CSS code, I notice it immediately when I see in the browser that CSS is nevermore valid.
Note: it also helps a lot to have 100% XHTML. Sometimes an invalid XHTML is caused by an error in code-behind.