我的 CSS 没有响应 ID 和 Class 标识符

My CSS isn't responding to ID and Class identifiers

我遇到了一个非常奇怪的问题。我只是想使用 ID 和 类 来编辑我的 HTML 和 CSS,但由于某种原因它没有被识别。这是我用过的HTML。

<p class="Benefits" ><center>Benefits of First Person Shooters</center></p>

这是CSS

.Benefits {
font-size: 60px;
}

ID 也不会响应。

添加的中心选择器具有与 Benefits 相同的字体大小 class

   .Benefits, center  {
      font-size: 60px;
    }

    <p class="Benefits" ><center>Benefits of First Person Shooters</center></p>

如果您检查 HTML,您会注意到中心标记位于段落之外。将 class/id 添加到中心标记而不是段落,或者使用 CSS 使文本居中而不是使用中心标记。

center 标记放在段落中会创建浏览器尝试修复的无效标记。还有:

The 'center' tag is not supported in HTML5. Use CSS instead.

.Benefits {
  font-size: 60px;
  text-align: center;
}
<p class="Benefits">Benefits of First Person Shooters</p>

因为它在 "center" 元素中。把你的 class 放在 "center".

之内