CSS общий элемент имеет приоритет над классами?

#html #css #inheritance

#HTML #css — код #наследование

Вопрос:

 ul {
  width: 250px;
}
li {
  margin: 10px;
}
ul.illuminations {
  list-style-position: outside;
}
ul.season {
  list-style-position: inside;
}
ul.2 {
  list-style: inside circle;
  width: 300px;
}
li.3 {
  margin: 100px;
} 
 <ul class="illuminations">
  <li>That idol, black eyes and yellow mop, without parentsw our court ...</li>
  <li>Gracious son of Pan! Around your forehead crowned with flowerets ...</li>
  <li>When the world is reduced to a single dark wood for our four...</li>
</ul>
<hr />
<ul class="season">
  <li>Once, if my memory serves me well, my life was a banquet...</li>
  <li>Hadn't I once a youth that was lovely, heroic, and fabulous...</li>
  <li>Autumn already! - But why regret the everlasting sun if we are</li>
</ul>
<hr />
<h1>Quotes from Edgar Allan Poe</h1>
<ul class="2">
  <li class="3">I have great faith in fools; self-confidence my friends call it.</li>
  <li class="3">All that we see or seem is but a dream within a dream.</li>
  <li class="3">I would define, in brief, the poetry of words as the rhythmical creation of beauty.</li>
</ul> 

Первые два списка действительно приобретают разные позиции маркеров. Однако последний список не приобретает атрибуты стиля и ширины списка, которые я намереваюсь использовать, используя более конкретные объявления. Это проблема, с которой я сталкивался уже много раз. Почему это так и как я должен ориентироваться на определенные элементы, чтобы переопределить атрибуты?

Комментарии:

1. Имена классов не могут начинаться с числа.

Ответ №1:

Идентификаторы CSS не могут начинаться с цифры. So .2 и .3 являются недопустимыми селекторами. Вы можете избежать их как .32 и .33 .

 ul {
  width: 250px;
}
li {
  margin: 10px;
}
ul.32 {
  list-style: inside circle;
  width: 300px;
}
li.33 {
  margin: 100px;
} 
 <ul class="2">
  <li class="3">I have great faith in fools; self-confidence my friends call it.</li>
  <li class="3">All that we see or seem is but a dream within a dream.</li>
  <li class="3">I would define, in brief, the poetry of words as the rhythmical creation of beauty.</li>
</ul>