首页 > 解决方案 > 如何更改我在css中文本的颜色?

问题描述

我想更改两种不同类型描述的颜色。我希望两种不同描述的文本显示为两种不同的颜色。我希望站点描述的文本显示为紫色,并且每个艺术家姓名下方的音乐家摘要文本显示为亮粉色。

    <!DOCTYPE html>
<html>
<body>
<head>
<title>My Music Website</title>
<style>
.musician-summary{
  color: blue;
}
#site-description{
  color: red;
}
</style>
</head>
</body>
<h1>My Music Website</h1>
<p id="site description"> Check out some of my favorite musical artists 
from around the world.</p>
<hr>
<h2 class="musician title">Stephane Wrembel</h2>
<p class="musician summary">His biggest influence and
  inspiration is Django Reinhardt. His music
is in the style of gypsy jazz. He learned
how to play directly from gypsies while living
with them for a few years.
Mysticism is a big theme in much of his
music. He plays many French standards
and his own compositions.</p>

<h2 class="musician title">Bjork</h2>
<p class="musician summary">Bjork has always shown a musical ability.
At the age of 11 she recorded her first album.
She gained fame outside of her country in the Icelandic punk band
The Sugarcubes, and later on went solo.
Her solo music is very ecclectic.
It ranges from hip-hop with some rhythms, classical, electronic, and she 
has been dubbed as the queen
of trip hop due to her use of hip hop beats.</p>

<h2 class="musician title">Sima Bina</h2>
<p class="musician summary">In Iran she is called Maestra Sima Bina. Her 
music is played in styles that are from and around Iran.</p>

标签: csstextcolors

解决方案


您的 CSS 选择器和 HTML 中的类/ID 不同;您在 ID 和类上有一个空格,并-在 HTML 中使用。将你的类和ID设置为与CSS中相同的名称;musician-summarysite-description。顺便说一句,如果您在类或 Id 名称中使用空格,它会创建 2 个类/ID


推荐阅读