在html中的css样式,子元素从父元素继承属性,是不是指标签里会继承上一级标签的属性

例:<div style="color:red;"><p>123456<p></div>那么123456是不是红色
2025-03-26 16:07:41
推荐回答(4个)
回答1:

是红色

css样式表属性可以继承的有如下:
azimuth, border-collapse, border-spacing,
caption-side, color, cursor, direction, elevation,
empty-cells, font-family, font-size, font-style,
font-variant, font-weight, font, letter-spacing,
line-height, list-style-image, list-style-position,
list-style-type, list-style, orphans, pitch-range,
pitch, quotes, richness, speak-header, speaknumeral,
speak-punctuation, speak, speechrate,
stress, text-align, text-indent, texttransform,
visibility, voice-family, volume, whitespace,
widows, word-spacing

回答2:

在P标签没有定义颜色的时候,是继承父元素的红色。

回答3:

这个是红色的,如果你在全局定义里p单独有定义颜色,那么可能就不是红色了。

回答4:

那么123456是红色