CSS Flashcards
What are the names of the individual pieces of a CSS rule?
css selector and declaration block (properties and values)
In CSS, how do you select elements by their class attribute?
with a dot and the class name
In CSS, how do you select elements by their type?
with the element’s name
In CSS, how do you select an element by its id attribute?
with the # character
Name three different types of values you can use to specify colors in CSS.
RGB values, hex codes, color names
What CSS properties make up the box model?
margin, padding, border (and content but content is not a property)
Which CSS property pushes boxes away from each other?
margin
Which CSS property adds space between a box’s content and its border?
padding
What is a pseudo-class?
a keyword added to a selector (hover, active, focus, etc) that specifies a special state of the selected element(s)
ex: :hover can be used to change a button’s color when the user’s pointer hovers over it
a keyword that is used to apply a selector to a specific state (certain thing happening in user interaction, history of the navigator– when you click on a link, it turns purple)
a psuedo class is a class apply by a browser to an element in certain situation
What are CSS pseudo-classes useful for?
they let you apply a style to an element when a specified action (such as hovering) occurs
Name at least two units of type size in CSS.
px and rem
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
What is the default flex-wrap of a flex container?
nowrap
Why do two div elements “vertically stack” on one another by default?
because div is a block element and it takes up the whole width so the next div has to start on a new line
What is the default flex-direction of an element with display: flex?
row
What is the default value for the position property of HTML elements?
position: static (normal flow of webpage)
How does setting position: relative on an element affect document flow?
it doesn’t affect the flow, it just overlaps them and shifts the elements
How does setting position: relative on an element affect where it appears on the page?
it moves the element relative to the normal placement (ex: position relative top: 10px means offset 10px FROM the top)
How does setting position: absolute on an element affect document flow?
the document acts like the element doesn’t exist
How does setting position: absolute on an element affect where it appears on the page?
its going to affect it where it appears on the page by getting out of the element ? completely and finds the closest nonstatic element
you only use position: absolute when you multiple layers of elements you want to overlay and you want element in a relative container (if you don’t set a relative container, then its going to position within the viewport/html
How do you constrain an absolutely positioned element to a containing block?
absolute position element needs to be inside an element that has a position set (such as relative position)
What are the four box offset properties?
right, left, top, bottom
Give two examples of media features that you can query in an @media rule.
width and device width
Which HTML meta tag is used in mobile-responsive web pages?
viewport metatag
The transition property is shorthand for which four CSS properties?
transition-property, transition-duration, transition-timing-function, transition-delay
What does the transform property do?
lets you rotate, scale, skew, or translate an element
Give four examples of CSS transform functions.
translate(), scale(), rotate(), skew()
What is a breakpoint in responsive Web design?
the point at which media query is used
a mark at some sort where new styling is introduced
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?
when you miminize or maximize your screen the element will resize up to the percentage you specified at
using percentage allows for more percentage and works with every viewport. you will still have to specify the width for certain viewport but it wont be as many as pixels
percentage possibly provide less styling than pixels
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?
code at the bottom takes precedence over code above
what we’re dealing with here is source order
media queries are completely reliance on source order to do their job