CSS Flashcards
what are the names of the individual pieces of a CSS rule?
selector, declaration block, property, value
how do you select elements by their class attribute?
.class element
how do you select elements by their type?
element name {}
how do you select an element by its id attribute?
id element
Name three different types of values you can use to specify colors in CSS
RGB values, hex code, color name
rgb a , hsl , hsl a
what css properties make up the box model?
content(height, width), padding, border, margin
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 css pseudo class is a keyword added to a selector that specifies a special state of the selected element. ex) :hover can be used to change a button’s color when the user’s pointer hovers over it.
what are css pseudo classes useful for?
Pseudo classes let you apply a style to an element not only in relation to the content of the document tree, but also in relation to “external factors” like the history of the navigator(:visited), the status of its content(:checked), or position of the mouse (:hover)
Name two types of units that can be used to adjust font-size in CSS.
rem, px, 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 in ltr; right to left in rtl
what is the default ‘felx-wrap’ of a flex container?
nowrap : all flex items will be on one line
why do two div elements “vertically stack” on one another by default?
images default is set to full width .
what is the default flex-direction of an element with display:flex?
left to right (row)
what is the default value for the position property of HTML elements?
static
How does setting ‘position: relative’ on an element affect document flow?
relative positioning moves an element in relation to where it would have been in normal flow.
How does setting ‘position: relative’ on an element affect where it appears on the page?
After indicating that an element should be relatively positioned using the position property with a value of relative, you can use the offset properties to indicate how far to move the element from where it would have been in the normal flow (top right bottom left)
- exactly the same. now it’s just positioned.
How does setting ‘position:absolute’ on an element affect document flow?
The box is taken out of normal flow and no longer affects the position of other elements on the page. ( they act like it is not there )
- act like elements not exist. big sweeping change.
How does setting position:absolute on an element affect where it appears on the page?
moves the element to the element that is not static?
How do you constrain an absolutely positioned element to a containing block?
by using the value not static.
what are the four box offset properties?
top right bottom and left
what are the four components of “the Cascade”?
source order, specificity, inheritance, important rule
what does the term “source order” mean with respect to CSS?
If you have more than one rule, which has exactly the same weight, then the one that comes last in the CSS will win. You can think of this as rules which are nearer the element itself overwriting early ones until the last one wins and gets to style the element.
how is it possible for the styles of an element to be applied to its children as well without an additional css rule?
inheritance. certain style to the parent and it will be applied to the children unless they have more specific styling
list the three selector types in order of increasing specificity.
type selectors, class selectors, id selectors.
why is using !important considered bad practice?
it’s hard to debug and improve the original style.
the only way to override it is to add another important rule or use javascript… which is bad.
what does the transform property do?
it lets you rotate, scale, skew or translate an element. it modifies the coordinate space of the CSS visual formatting model.
give four examples of css transform functions
translateX,Y,Z perspective
Give two examples of media features that you can query in an @media rule
width height,, things that look like a property but its not a real property
which html meta tag is used in mobile-responsive web pages?
viewport
the transition property is shorthand for which four css properties?
transition-property, transition-duration, transition-timing-function, transition-delay
what is a ‘breakpoint’ in responsive web design?
In responsive design, a breakpoint is the “point” at which a website’s content and design will adapt in a certain way in order to provide the best possible user experience
ex) width
what is the advantage of using a percentage width instead of a fixed width for a “column” class in a responsive layout?
It is often used to define a size as relative to an element’s parent object.
we don’t know how the user’s screen is gonna be,
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 it?
cascade. source order applies even when using media queries. pay attention on where your media queries are applied.