2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								id: 58c383d33e2e3259241f3076
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								title: Use Attribute Selectors to Style Elements
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								challengeType: 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								videoUrl: 'https://scrimba.com/c/cnpymfJ'
							 
						 
					
						
							
								
									
										
										
										
											2019-08-05 09:17:33 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								forumTopicId: 301092
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								---
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Description
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< section  id = 'description' >  
						 
					
						
							
								
									
										
										
										
											2019-11-25 11:14:08 -05:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								You have been adding < code > id< / code >  or < code > class< / code >  attributes to elements that you wish to specifically style. These are known as ID and class selectors. There are other CSS Selectors you can use to select custom groups of elements to style.
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								Let's bring out CatPhotoApp again to practice using CSS Selectors.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								For this challenge, you will use the < code > [attr=value]< / code >  attribute selector to style the checkboxes in CatPhotoApp. This selector matches and styles elements with a specific attribute value. For example, the below code changes the margins of all elements with the attribute < code > type< / code >  and a corresponding value of < code > radio< / code > :
							 
						 
					
						
							
								
									
										
										
										
											2019-05-14 01:11:58 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```css
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								[type='radio'] {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  margin: 20px 0px 20px 0px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / section >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Instructions
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< section  id = 'instructions' >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Using the < code > type< / code >  attribute selector, try to give the checkboxes in CatPhotoApp a top margin of 10px and a bottom margin of 15px.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / section >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Tests
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< section  id = 'tests' >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```yml
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								tests:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  -  text: The < code > type</ code >  attribute selector should be used to select the checkboxes.
							 
						 
					
						
							
								
									
										
										
										
											2019-07-24 02:50:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    testString: assert(code.match(/< style > [ \s\S]*? \[type=("|')checkbox \1\]\s*?{[ \s\S]*?}[ \s\S]*?< \/style>/gi)); 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  text: The top margins of the checkboxes should be 10px.
							 
						 
					
						
							
								
									
										
										
										
											2019-07-24 02:50:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    testString: assert((function() {var count=0; $("[type='checkbox']").each(function() { if($(this).css('marginTop') === '10px') {count++;}});return (count===3)}()));
							 
						 
					
						
							
								
									
										
										
										
											2018-10-04 14:37:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  -  text: The bottom margins of the checkboxes should be 15px.
							 
						 
					
						
							
								
									
										
										
										
											2019-07-24 02:50:51 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    testString: assert((function() {var count=0; $("[type='checkbox']").each(function() { if($(this).css('marginBottom') === '15px') {count++;}});return (count===3)}()));
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / section >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Challenge Seed
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< section  id = 'challengeSeed' >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< div  id = 'html-seed' >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< link  href = "https://fonts.googleapis.com/css?family=Lobster"  rel = "stylesheet"  type = "text/css" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< style >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .red-text {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    color: red;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  h2 {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    font-family: Lobster, monospace;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    font-size: 16px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    font-family: monospace;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .thick-green-border {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-color: green;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-width: 10px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-style: solid;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-radius: 50%;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .smaller-image {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    width: 100px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .silver-background {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    background-color: silver;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / style >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< h2  class = "red-text" > CatPhotoApp< / h2 >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< main >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < p  class = "red-text" > Click here to view more < a  href = "#" > cat photos< / a > .< / p > 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-08 01:01:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  < a  href = "#" > < img  class = "smaller-image thick-green-border"  src = "https://bit.ly/fcc-relaxing-cat"  alt = "A cute orange cat lying on its back." > < / a > 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-08 01:01:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  < div  class = "silver-background" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < p > Things cats love:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > cat nip< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > laser pointers< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > lasagna< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < p > Top 3 things cats hate:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < ol > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > flea treatment< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > thunder< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > other cats< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / ol > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < / div > 
							 
						 
					
						
							
								
									
										
										
										
											2018-10-08 01:01:53 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								  < form  action = "/submit-cat-photo"  id = "cat-photo-form" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "radio"  name = "indoor-outdoor"  checked >  Indoor< / label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "radio"  name = "indoor-outdoor" >  Outdoor< / label > < br > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "checkbox"  name = "personality"  checked >  Loving< / label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "checkbox"  name = "personality" >  Lazy< / label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "checkbox"  name = "personality" >  Energetic< / label > < br > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < input  type = "text"  placeholder = "cat photo URL"  required > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < button  type = "submit" > Submit< / button > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < / form > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / main >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / div >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / section >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## Solution
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< section  id = 'solution' >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-22 01:57:43 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								```html
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< link  href = "https://fonts.googleapis.com/css?family=Lobster"  rel = "stylesheet"  type = "text/css" >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< style >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .red-text {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    color: red;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  h2 {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    font-family: Lobster, monospace;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  p {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    font-size: 16px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    font-family: monospace;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .thick-green-border {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-color: green;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-width: 10px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-style: solid;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    border-radius: 50%;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .smaller-image {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    width: 100px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  .silver-background {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    background-color: silver;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  [type='checkbox'] {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    margin-top: 10px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    margin-bottom: 15px;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / style >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< h2  class = "red-text" > CatPhotoApp< / h2 >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< main >  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < p  class = "red-text" > Click here to view more < a  href = "#" > cat photos< / a > .< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < a  href = "#" > < img  class = "smaller-image thick-green-border"  src = "https://bit.ly/fcc-relaxing-cat"  alt = "A cute orange cat lying on its back." > < / a > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < div  class = "silver-background" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < p > Things cats love:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > cat nip< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > laser pointers< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > lasagna< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / ul > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < p > Top 3 things cats hate:< / p > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < ol > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > flea treatment< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > thunder< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      < li > other cats< / li > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < / ol > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < / div > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < form  action = "/submit-cat-photo"  id = "cat-photo-form" > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "radio"  name = "indoor-outdoor"  checked >  Indoor< / label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "radio"  name = "indoor-outdoor" >  Outdoor< / label > < br > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "checkbox"  name = "personality"  checked >  Loving< / label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "checkbox"  name = "personality" >  Lazy< / label > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < label > < input  type = "checkbox"  name = "personality" >  Energetic< / label > < br > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < input  type = "text"  placeholder = "cat photo URL"  required > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < button  type = "submit" > Submit< / button > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  < / form > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< / main >  
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								```
							 
						 
					
						
							
								
									
										
										
										
											2019-07-18 08:24:12 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-09-30 23:01:58 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								< / section >