CSS - Linkedin Flashcards
Q1. In the following example, which selector has the highest specificity ranking for selecting the anchor link element?
ul li a
a
.example a
div a
.example a
Q2. Using an attribute selector, how would you select an <a> element with a “title” attribute?</a>
a[title]{…}
a > title {…}
a.title {…}
a=title {…}</a>
a[title]{…}
Q3. CSS grid and flexbox are now becoming a more popular way to create page layouts. However, floats are still commonly used, especially when working with an older code base, or if you need to support older browser version. What are two valid techniques used to clear floats?
- Use the “clearfix hack” on the floated element and add a float to the parent element.
- Use the overflow property on the floated element or the “clearfix hack” on either the floated or parent element.
- Use the “clearfix hack” on the floated element or the overflow property on the parent element.
- Use the “clearfix hack” on the parent element or use the overflow property with a value other than “visible.”
Use the “clearfix hack” on the parent element or use the overflow property with a value other than “visible.”
Q4. What element(s) do the following selectors match to?
1) .nav { ...; } 2) nav { ...; } 3) #nav { ...; }
- An element with an class of “nav”
- A nav element
- An element 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?
- Opacity specifies the level of transparency of the child elements. Background with an rgba() value applies transparency to the background color only.
- Opacity applies transparency to the background color only. Background with an rgba() value specifies the level of transparency of an element, as a whole, including its content.
- Opacity specifies the level of transparency of an element, including its content. Background with an rgba() value applies transparency to the background color only.
- Opacity applies transparency to the parent and child elements. Background with an rgba() value specifies the level of transparency of the parent element only.
Opacity specifies the level of transparency of an element, including its content. Background with an rgba() value applies transparency to the background color only.
Q6. What is true of block and inline elements? Alternative: Which statement about block and inline elements is true?
- By default, block elements are the same height and width as the content container between their tags; inline elements span the entire width of its container.
- By default, block elements span the entire width of its container; inline elements are the same height and width as the content contained between their tags.
- nav element is an example of an inline element. header is an example of a block element.
- span is an example of a block element. div is an example of an inline element.
By default, block elements span the entire width of its container; inline elements are the same height and width as the content contained between their tags.
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; }
- The first column will have a width of 50px. The second column will be 50px wide and the third column will be 100px wide.
- The first column will have a width of 50px. The second column will be 150px wide and the third column will be 300px wide.
- The first column will have a width of 50px. The second column will be 300px wide and the third column will be 150px wide.
- The first column will have a width of 50px. The second column will be 500px wide and the third column will be 1000px wide.
The first column will have a width of 50px. The second column will be 150px wide and the third column will be 300px wide.
Q8. What is the line-height property primarily used for?
to control the height of the space between two lines of content
to control the height of the space between heading elements
to control the height of the character size
to control the width of the space between characters
to control the height of the space between two lines of content
Q9. Three of these choices are true about class selectors. Which is NOT true?
- Multiple classes can be used within the same element.
- The same class can be used multiple times per page.
- Class selectors with a leading period
- Classes can be used multiple times per page but not within the same element.
Classes can be used multiple times per page but not within the same element.
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?
position
flexbox
grid
float
position
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;
Q12. In the following example, according to cascading and specificity rules, what color will the link be?
.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>
yellow
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. What do you know about z-index?
Larger z-index values appear on top of elements with a lower z-index value. Negative and positive numbers can be used. z-index can only be used on positioned elements.
Q14. What is the difference between the following line-height settings?
line-height: 20px;
line-height: 2;
The value of 20px will set the line-height to 20px. The value of 2 will set the line-height to twice the size of the corresponding font-size value.
Q15. In the following example, what color will paragraph one and paragraph two be? (Alternative: In this example, what color will paragraphs one and two be?)
<p>paragraph one</p>
<p>paragraph two</p>
section p {
color: red;
}
section + p {
color: blue;
}
Paragraphs one will be red, paragraph two will be blue.
Q16.What are three valid ways of adding CSS to an HTML page?
- External; CSS is written in a separate file and is linked within the element of the HTML file.
- Inline; CSS is added to the HTML tag.
- Internal; CSS is included within the element of the HTML file.
Q17. Which of the following is true of the SVG image format? (Alternative: Which statement about the SVG image format is true?)
- CSS can be applied to SVGs but JavaScript cannot be.
- SVGs work best for creating 3D graphics.
- SVGs can be created as a vector graphic or coded using SVG specific elements such as svg, line, and ellipse.
- SVGs are a HAML-based markup language for creating vector graphics.
SVGs can be created as a vector graphic or coded using SVG specific elements such as svg, line, and ellipse.
Q18. In the example below, when will the color pink be applied to the anchor element?
a:active {
color: pink;
}
The color of the link will display as pink while the link is being clicked but before the mouse click is released.
Q19. To change the color of an SVG using CSS, which property is used?
Use fill to set the color inside the object and stroke to set the color of the border.
Q20. When using position: fixed, what will the element always be positioned relative to?
the viewport
Q21. By default, a background image will repeat _
indefinitely, vertically, and horizontally
Q22. When using media queries, media types are used to target a device category. Which choice lists current valid media types?
print, screen, speech
Q23. How would you make the first letter of every paragraph on the page red?
p::first-letter { color: red; }
Q24. In this example, what is the selector, property, and value?
p {
color: #000000;
}
“p” is the selector
“color” is the property
“#000000” is the value
Q25. What is the rem unit based on?
The rem unit is relative to the font-size of the root element of the page.
Q26.Which of these would give a block element rounded corners?
corner-curve: 10px
border-corner: 10px
border-radius: 10px
corner-radius: 10px
border-radius: 10px
Q27. In the following media query example, what conditions are being targeted?
@media (min-width: 1024px), screen and (orientation: landscape) { … }
The rule will apply to a device that has either a width of 1024px or wider, or is a screen device in landscape mode.
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?
the top left corner of the element
Q29. Which of the following is not a valid color value? (Alternative: Which choice is not a valid color value?)
color: #000
color: rgb(0,0,0)
color: #000000
color: 000000
color: 000000
Q30. What is the vertical gap between the two elements below?
<div>Div 1</div>
<div>Div 2</div>
2rem
32px
64px
4rem
2rem
Q31. When using the Flexbox method, what property and value is used to display flex items in a column?
flex-flow: column; (or flex-direction: column)
flex-flow: column;
flex-column: auto;
flex-direction: column;
flex-flow: column; or flex-direction: column
Q32. Which type of declaration will take precedence?
any declarations in user-agent stylesheets
important declarations in user stylesheets
normal declarations in author stylesheets
important declarations in author stylesheets
important declarations in user stylesheets
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; }
<p>paragraph 1</p>
<h2>Heading</h2>
<p>paragraph 2</p>
<p>paragraph 3</p>
Paragraphs 2, and 3 will be blue, and paragraph 2 will have a beige background.
Q36. There are many advantages to using icon fonts. What is one of those advantages?
Icon fonts can be styled with typography related properties such as font-size and color.
Q37. What is the difference between display:none and visibility:hidden?
display:none hides the element from view and removes it from the normal flow of the document. visibility:hidden will hide the element but maintains the space it previously occupied.
Q38. What selector and property would you use to scale an element to be 50% smaller on hover?
element:hover {transform: scale(0.5);}
Q39. Which statement regarding icon fonts is true?
- Icon fonts can be inserted only using JavaScript.
- Icon fonts are inserted as inline images.
- Icon fonts require browser extensions.
- Icon fonts can be styled with typography-related properties such as font-size and color.
Icon fonts can be styled with typography-related properties such as font-size and color.
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;
- bold; normal
- normal; bold
- light; normal
- normal; bolder
normal; bold
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; }
50px, 150px, 300px
50px, 200px, 300px
50px, 100px, 200px
50px, 50px, 100px
50px, 150px, 300px
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(3n + 2) {
margin: 0 5 px;
}
Q43. Which selector would select only internal links within the current page?
a[href=”#”] {…}
a[href~=”#”]
a[href^=”#”]
a[href=”#”]
a[href^=”#”]
Q44. What is not true about class selectors?
- Only one class value can be assigned to an element.
- An element can have multiple class value.
- Class selectors are marked with a leading period.
- More than one element can have the same class value.
Only one class value can be assigned to an element.
Q45. What is the difference between the margin and padding properties?
Margin adds space around an element; padding adds space inside of an element.
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?
padding: 10px 10px 0px 0px;
padding: 10px 0px;
padding: 10px 0;
padding: 10px 0px 10px 0px;
padding: 10px 10px 0px 0px;
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’);
}
The sans-serif inclusion is problematic.
Q48. Which style places an element at a fixed location within its container?
position: absolute;
display: flex;
display: block;
float: left;
position: absolute;
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);
}
The left margin value is equal to 5% of its parents element’s width plus 5px
Q50. What is the CSS selector for an <a> tag containing the title attribute?</a>
a[title]
a > title
a=title
a.title</a>
a[title]