CSS Assessment


ul li a
a
.example a
div a

Q2. Using an attribute selector, how would you select an <a> element with a "title" attribute?

Q4. What element(s) do the following selectors match to?

1) .nav {...}
2) nav {...}
3) #nav {...}

1) An element with an ID of "nav"
2) A nav element
3) An element with a class of "nav"
They all target the same nav element.
1) An element with an class of "nav"
2) A nav element
3) An element with a id of "nav"
1) An element with an class of "nav"
2) A nav element
3) An div with a id of "nav"

Q5. When adding transparency styles, what is the difference between using the opacity property versus the background property with an rgba() value?

Q6. What is true of block and inline elements?

Q7. CSS grid introduced a new length unit, fr, to create flexible grid tracks. Referring to the code sample below, what will the widths of the three columns be?

.grid {
  display: grid;
  width: 500px;
  grid-template-columns: 50px 1fr 2fr;
}

Q8. What is the line-height property primarily used for?

Q9. Three of these choices are true about class selectors. Which is NOT true?

Q10. There are many properties that can be used to align elements and create page layouts such as float, position, flexbox and grid. Of these four properties, which one should be used to align a global navigation bar which stays fixed at the top of the page?

Q11. In the shorthand example below, which individual background properties are represented?

background: blue url(image.jpg) no-repeat scroll 0px 0px;

background-color: blue;
background-image: url(image.jpg);
background-repeat: no-repeat;
background-attachment: scroll;
background-position: 0px 0px;
background-color: blue;
background-img: url(image.jpg);
background-position: no-repeat;
background-scroll: scroll;
background-size: 0px 0px;
background-color: blue;
background-src: url(image.jpg);
background-repeat: no-repeat;
background-wrap: scroll;
background-position: 0px 0px;
background-color: blue;
background-src: url(image.jpg);
background-repeat: no-repeat;
background-scroll: scroll;
background-position: 0px 0px;
.example {
  color: yellow;
}
ul li a {
  color: blue;
}
ul a {
  color: green;
}
a {
  color: red;
}
<ul>
  <li><a href="#" class="example">link</a></li>
  <li>list item</li>
  <li>list item</li>
</ul>

Q13. When elements overlap, they are ordered on the z-axis (i.e., which element covers another). The z-index property can be used to specify the z-order of overlapping elements. Which set of statements about the z-index property are true?

Q14. What is the difference between the following line-height settings?

line-height: 20px
line-height: 2

Q15. In the following example, what color will paragraph one and paragraph two be?

<section>
  <p>paragraph one</p>
</section>

<p>paragraph two</p>
section p {
  color: red;
}
section + p {
  color: blue;
}

Q16.What are three valid ways of adding CSS to an HTML page?

1. External; CSS is written in a separate file.
2. Inline; CSS is added to the <head> of the HTML page.
3. Internal; CSS is included within the HTML tags.
1. External; CSS is written in a separate file and is linked within the <header> element of the HTML file.
2. Inline; CSS is added to the HTML tag.
3. Internal; CSS is included within the <header> element of the HTML  file.
1. External; CSS is written in a separate file and is linked within the <head> element of the HTML file.
2. Internal; CSS is included within the <header> element of the HTML file.
3. Inline; CSS is added to the HTML tag.
1. External; CSS is written in a separate file and is linked within the <head> element of the HTML file .
2. Inline; CSS is added to the HTML tag.
3. Internal; CSS is included within the <head> element of the HTML file.

Q17. Which of the following is true of the SVG image format?

Q18. In the example below, when will the color pink be applied to the anchor element?

a:active {
  color: pink;
}

Q19. To change the color of an SVG using CSS, which property is used?

Q20. When using position: fixed, what will the element always be positioned relative to?

Q21. By default, a background image will repeat ___

Q22. When using media queries, media types are used to target a device category. Which choice lists current valid media types?

Q23. How would you make the first letter of every paragraph on the page red?

Q24. In this example, what is the selector, property, and value?

p {
  color: #000000;
}
"p" is the selector
"#000000" is the property
"color" is the value
"p" is the selector
"color" is the property
"#000000" is the value
"color" is the selector
"#000000" is the property
"#p" is the value
"color" is the selector
"p" is the property
"#000000" is the value

Q25. What is the rem unit based on?

Q26.Which of these would give a block element rounded corners?

Q27. In the following media query example, what conditions are being targeted?

@media (min-width: 1024px), screen and (orientation: landscape) {}

Q28. CSS transform properties are used to change the shape and position of the selected objects. The transform-origin property specifies the location of the element's transformation origin. By default, what is the location of the origin?

Q29. Which of the following is not a valid color value?

Q30. What is the vertical gap between the two elements below?

<div style="margin-bottom: 2rem;">Div 1</div>
<div style="margin-top: 2rem;">Div 2</div>

Q31. When using the Flexbox method, what property and value is used to display flex items in a column?

Q32. Which type of declaration will take precedence?

Q33. The flex-direction property is used to specify the direction that flex items are displayed. What are the values used to specify the direction of the items in the following examples?

Q34. There are two sibling combinators that can be used to select elements contained within the same parent element; the general sibling combinator (~) and the adjacent sibling combinator (+). Referring to example below, which elements will the styles be applied to?

h2 ~ p {
  color: blue;
}
h2 + p {
  background: beige;
}
<section>
  <p>paragraph 1</p>
  <h2>Heading</h2>
  <p>paragraph 2</p>
  <p>paragraph 3</p>
</section>

Q35. When using flexbox, the "justify-content" property can be used to distribute the space between the flex items along the main axis. Which value should be used to evenly distribute the flex items within the container shown below?

Q36. There are many advantages to using icon fonts. What is one of those advantages?

Q37. What is the difference between display:none and visibility:hidden?

Q38. What selector and property would you use to scale an element to be 50% smaller on hover?

Q39. Which statement regarding icon fonts is true?

Q40. The values for the font-weight property can be keywords or numbers. For each numbered value below, what is the associated keyword?

font-weight: 400; font-weight: 700;

Q41. If the width of the container is 500 pixels, what would the width of the three columns be in this layout?

.grid { display: grid; grid-template-columns: 50px 1fr 2fr; }

Q42. Using the :nth-child pseudo class, what would be the most efficient way to style every third item in a list, no matter how many items are present, starting with item 2?

li:nth-child(3 + 2n) {
  margin: 0 5 px;
}
li:nth-child(3n + 2) {
  margin: 0 5 px;
}
li:nth-child(2),
li:nth-child(5),
li:nth-child(8) {
  margin: 0 5 px;
}
li:nth-child(2n + 3) {
  margin: 0 5 px;
}

Q44. What is not true about class selectors?

Q45. What is the difference between the margin and padding properties?

Q46. What is not a valid way of declaring a padding value of 10 pixels on the top and bottom, and 0 pixels on the left and right?

Q47. Is there an error in this code? If so, find the best description of the problem

@font-face {
  font-family: 'Avenir', sans-serif;
  src:  url('avenir.woff2') format('woff2'),
        url('avenir.woff') format('woff');
}

Q48. Which style places an element at a fixed location within its container?

Q49. The calc() CSS function is often used for calculating relative values. In the example below, what is the specified margin-left value?

.example{
  margin-left: calc(5% + 5px);
}

Q50. What is the CSS selector for an <a> tag containing the title attribute?

Q51. Which code would you use to absolutely position an element of the logo class?

Q52. In this example, what color will Paragraph 1 be?

p:first-of-type {
  color: red;
}
p {
  color: blue;
}
.container {
  color: yellow;
}
p:first-child {
  color: green;
}
<div class="container">
  <h1>Heading</h1>
  <p>Paragraph1</p>
  <p>Paragraph2</p>
</div>