CSS Flashcards
What are the names of the individual pieces of a CSS rule?
p {
font-family: Arial;
}
p = selector
font-family: Arial; = declaration
font-family: = property
Arial = value
In CSS, how do you select elements by their class attribute?
.class-name { }
In CSS, how do you select elements by their type?
p { }
In CSS, how do you select an element by its id attribute?
ID-name{ }
Name three different types of values you can use to specify colors in CSS.
RGB Values
Hexadecimal Codes
Color Names
What CSS properties make up the box model?
Margin
Border
Padding
Content
Which CSS property pushes boxes away from each other?
Margin
Which CSS property add space between a box’s content and its border?
padding
What is a pseudo-class?
A way to select an element when its in a given state
Exp: being hovered
Currently being clicked on
What are CSS pseudo-classes useful for?
They let you apply different styling to elements when those elements are in their given states
Name at least two units of type size in CSS.
px
rem
em
What CSS property controls the font used for the text inside an element?
font-family:
What is the default flex-direction of a flex container?
row (Left to right)
What is the default flex-wrap of a flex container?
nowrap (everything goes in one line)
What is the default value for the position property of HTML elements?
Every element is status by default
How does setting position: relative on an element affect document flow?
It’ll transform the item from its original position while still holding its original space on the file
How does setting position: relative on an element affect where it appears on the page?
It’ll appear on the same place until transformations are added
How does setting position: absolute on an element affect document flow?
The surrounding elements act as if the moved item was never there to begin with.
How does setting position: absolute on an element affect where it appears on the page?
It’ll look for the first ancestor who is not set to position: static; (all by default)
What are the four box offset properties?
top
Bottom
Left
right
What are the four components of “the Cascade”.
Source Order
Inheritance
Specificity
!important
What does the term “source order” mean with respect to CSS?
If two different selectors are on the same specificity, the selector which is written lowest on your styles.css sheet will be applied to your HTML page.
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
By default, many styles affect the specified element and all children under it, through inheritance.
List the three selector types in order of increasing specificity.
Element
Class
ID
Why is using !important considered bad practice?
It breaks the natural cascading in your code so it would make debugging difficult.
What does the transform property do?
It allows you to take an element on your HTML page, and move it around, from its original position, with CSS
Give four examples of CSS transform functions.
transform: rotate(-50deg);
transform: translateY(0.25rem);
transform: translateX(0.25rem);
transform: scale(x%, y%);
The transition property is shorthand for which four CSS properties?
Its a single combination of transition-property, transition-duration, transition-timing-function, & transition-delay
Give two examples of media features that you can query in an @media rule.
Only screen
Only print
@media only screen and (min-width: 500px) { css codeblock }
Which HTML meta tag is used in mobile-responsive web pages?
Viewport meta tag
What is a breakpoint in responsive Web design?
What does it look like?
A given width of the screen where it would trigger different behaviors of styling to take place
@media only screen and (min-width: 500px) { img { width: 50%; } }
What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a “column” class in a responsive layout?
Percentages are based on the ever-changing size of the screen, so they adjust with the screen size.
Pixels are stuck to a certain size, no matter how large the screen. This would lead to items being too large for small screens or too small for large screens.
If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will “win”. Why is that?
The CSS follows the Source Order rule. The lowest item on the styles sheet takes precedence.