正确的语义使用CSS属性 [英] Correct Semantic use of CSS Properties

查看:141
本文介绍了正确的语义使用CSS属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于建议不要使用 table 元素作为布局(非表格数据),因为特殊的格式适用于这些元素将来可能会发生变化,也不建议使用CSS属性例如 text-align ,其设计用于文本,对于同一语义原因的 img 元素?

Since it is recommended not to use table elements for layout purposes (non-tabular data), because the special formatting applied to those elements may change in the future, is it also not recommended to use CSS properties such as text-align, which was designed to be used on text, for img elements for the same semantic reason?

我一直在通过w3c规范,例如, line-height 似乎是为文本目的设计的并且在文档中有大量的字体大小的引用,因此在 img 元素上使用此属性是合适的或滥用的,只是因为它们显示为 inline

I have been looking through the w3c specifications and for instance, line-height seems to be designed for text purposes and has plenty of references in the documentation to font size, so would it be appropriate or abusive to use this property on img elements, simply because they are displayed as inline?

我可以理解W3C对语义Web 将使用CSS从页面中删除样式信息,将数据专门留在HTML中以实现内容可访问性。但 在哪里是原始的原理文档,为什么他们不使用非常抽象的属性,如 horizo​​ntal-align 每个显示类型的唯一对齐方式(例如 text-align:center 可用于所有 display:inline img 元素)?

I can understand how the W3C idea of a Semantic Web would use CSS to remove styling information from a page, leaving data exclusively in the HTML for content accessibility. But where is the original rationale documentation for CSS, and why wouldn't they use extremely abstract properties like horizontal-align from the get go, instead of unique alignments for each display type (e.g. text-align: center can be used on all display: inline elements such as img elements) ?

推荐答案

否。 CSS纯粹是表现性的。一些属性命名不当(文本对齐是一个主要的例子,它是 以对齐所有内联子对象)。

No. CSS is purely presentational. Some of the properties are just poorly named (text-align being a prime example, it is designed to align all inline children).

这篇关于正确的语义使用CSS属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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