and nothing works, I tried: .p...">

Choosing div by id and class

I am trying to select this using both is and class:

<div class="phase" id="1"> 

and nothing works, I tried:

 .phase#1 #1.phase div#1.phase 

could it be #1 ? I have never encountered problems with numeric id

Update:
I seem to have confused jQuery selectors and CSS selectors,
this will work fine with jQuery:

 $(".phase#1") 

but this:

 .phase#1 {} 

Not working in CSS

+4
source share
2 answers

The id attribute indicates a unique identifier for the HTML element (the value must be unique in the HTML document). Therefore, if you selected by id, you should also not select by class.

Indicates the unique identifier of the item. Naming Rules:

  • You need to start with the letter AZ or az
  • It will be followed by: letters (A-Za-z), numbers (0-9), hyphens ("-") and underscores ("_")
  • In HTML, all values โ€‹โ€‹are case insensitive

HTML attribute attribute

+6
source

id cannot start with numeric values 1, 2, 3, etc They may contain numerical values, and not begin with them.

spec - http://www.w3.org/TR/html401/types.html#type-name

+11
source

Source: https://habr.com/ru/post/1412586/


All Articles