| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: Class Equals | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | ## Class Equals
 | 
					
						
							| 
									
										
										
										
											2018-11-04 11:33:22 +11:00
										 |  |  | To select an item with a class attribute, you use the following selector: | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-04 11:33:22 +11:00
										 |  |  | ```css | 
					
						
							|  |  |  | p[class="happy"] { | 
					
						
							|  |  |  |     color: yellow; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-04 11:33:22 +11:00
										 |  |  | This selector is not commonly used, as there is a general class selector. We can rewrite the above selector like this: | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-04 11:33:22 +11:00
										 |  |  | ```css | 
					
						
							|  |  |  | p.happy { | 
					
						
							|  |  |  |     color: yellow; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | #### More Information:
 | 
					
						
							| 
									
										
										
										
											2018-11-04 11:33:22 +11:00
										 |  |  | https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors |