Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting 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 the #1? I never ran into problems with a numeric id

Update:
It seems I confused jQuery selectors and CSS selectors,
this would work fine with jQuery:

$(".phase#1")

but this:

.phase#1 {}

Will not work in CSS

like image 602
ilyo Avatar asked Dec 04 '22 03:12

ilyo


2 Answers

id's cannot start with numeric values 1, 2, 3, etc. They can contain numeric values, just not start with them.

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

like image 159
Alex Avatar answered Dec 27 '22 09:12

Alex


The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document). So if you selected by id you shouldn't also selected by class.

Specifies a unique id for the element. Naming rules:

  1. Must begin with a letter A-Z or a-z
  2. Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), and underscores ("_")
  3. In HTML, all values are case-insensitive

HTML id Attribute specification

like image 28
Eugene Trofimenko Avatar answered Dec 27 '22 10:12

Eugene Trofimenko