【发布时间】:2009-03-15 04:21:32
【问题描述】:
我的网站目前有一些通用的 H1、H2、H3 样式,它们非常适合大多数需要简单“传统”标题的“通用”标题。
h1 { /* lots of style attributes */ }
h2 { /* lots of style attributes */ }
h3 { /* lots of style attributes */ }
我也在创建一些组件,我有这样的东西,也就是说我需要一个特定于该特定类型控件的标题。
<div class="titledimage"><h1>Section header</h1><img .../></div>
.titledimage h1 { color:red; bottom-border: 1px solid blue; }
我遇到的问题是titledimage下的h1也是前面定义的h1,所以它继承了h1定义的所有样式。这通常是不希望的 - 我只想要 red 和 1px solid blue 作为 .titledImage div 中的标题。
我正在阅读并尝试回答 this question about H1 styles。我的结论是,如果你正在做特定的标题样式(.titledimage h1),你不能真正做通用的标题样式(h1),除非:
a) you reset every style attribute in the '.titledimage h1' style
b) you just use a class name instead of h1
c) your `h1` style is defined with very few attributes that you'd
be overriding anyway
我注意到他们实际上使用H6 来设置YUI menu control 的样式,我想知道他们是否这样做是为了避免此类冲突。
我应该
a) be using <h6> like yahoo does?
b) reset every attribute defined by `h1` when I define `.titledimage h1` ?
c) just use a class name for `.titledimage header`, and leave
`h1`, `h2`, `h3` for 'traditional more logical headers'
d) something else
理想情况下我想说这个,但没有这样的事情(据我所知)
.titledimage h1 { inherit: none; color:red; bottom-border: 1px solid blue; }
【问题讨论】:
-
@daniel - 完成。它在我想要它之前发布,但我不确定欺骗是如何发生的。
-
你能发布你的 HTML 的一般结构吗?在大多数情况下,我认为拥有很多 H1 并不是很有用。
-
@strager - 你看到问题 503925 了吗?所以你建议什么 - h2 ;-) ?我倾向于 yahoo 对他们的
所做的事情。如果它是合法的标题,它至少应该是 H 的东西。这些天我需要安装一个屏幕阅读器,看看可访问性是如何工作的
-
@Simon,通常,标题应该能够创建目录。 (Opera:View->Style->ToC)SO 不是一个很好的例子,但是 Wikipedia 是。
-
@strager - 好点。看看雅虎的主页(我假设你得到了新版本)。他们有带有标题的面板,例如“今日热门搜索”。这些就是我正在谈论的事情。这些可能是目录的好候选
标签: css