CSS Flashcards
(37 cards)
• What are the names of the individual pieces of a CSS rule?
o Selector, declaration block, property, value.
• In CSS, how do you select elements by their class attribute?
o Use a period “.class”
• In CSS, how do you select elements by their type?
o Simply write the element name – nothing else.
• In CSS, how do you select an element by its id attribute?
o Use a # sign
• Name three different types of values you can use to specify colors in CSS.
o rbg, hex codes, name of colors, etc.
• Name three different types of values you can use to specify colors in CSS.
o rgb, hex codes, name of colors, etc.
• What CSS properties make up the box model?
o Border, margin, padding (page 307), and content
• Which CSS property pushes boxes away from each other?
o The MARGIN is an invisible space around your box.
o It pushes other elements AWAY from the box.
o Margins can have positive or negative values. Setting a negative margin on one side of your box can cause it to overlap other things on the page. Whether you are using the standard or alternative box model, the margin is always added after the size of the visible box has been calculated.
• Which CSS property add space between a box’s content and its border?
o Padding
o Padding is the space between the border of a box and any content contained within it. Adding padding can increase the readability of its contents.
Padding is additional space – and that comes with problems.
Box-sizing border box – it makes it so that the sizing is applied to the border and that which is inside of it.
• What is a pseudo-class?
o A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s). o For example, :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?
o SCALABILITY – no need to write long code if you can have it uniform.
o 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, for example), the status of its content (like :checked on certain form elements), or the position of the mouse (like :hover, which lets you know if the mouse is over an element or not).
o Applying style
o nth child
• Name two types of units that can be used to adjust font-size in CSS.
o em
o px
o ##%
• What CSS property controls the font used for the text inside an element?
o font-family
o The font CSS shorthand property sets all the different properties of an element’s font. Alternatively, it sets an element’s font to a system font.
• What is the default flex-direction of a flex container?
o row
• What is the default flex-wrap of a flex container?
o No wrap
• Why do two div elements “vertically stack” on one another by default?
o They are block level elements
• What is the default flex-direction of an element with display: flex?
o Row
o Purpose of the container class – is the boundary for all of our content.
• What is the default value for the position property of HTML elements?
o Static or Normal flow
o Every block-level element appears on a new line – causing each item to appear lower down the page than the previous one.
o Even if you specify the width of the boxes and there is space for two elements to sit side by side, they will not appear next to each other.
o The paragraphs appear one after the other, vertically down the page.
• How does setting position: relative on an element affect document flow?
o This moves an element from the position it would be in normal flow, shifting it to the top, right, bottom, or left of where it would have been placed.
o This DOES NOT AFFECT the position of surrounding elements.
o They stay in the position they would be in normal flow.
THINK INDENTATION?
• How does setting position: relative on an element affect where it appears on the page?
• How does setting position: absolute on an element affect document flow?
o Absolute positions the element in relation to its CONTAINING element
o It is taken OUT of normal flow – meaning that it DOES NOT affect the position of any surrounding elements
They ignore the space it would have taken up.
o ABSOLUTE positioned elements move as users scroll up and down the page.
o It is COMPLETELY REMOVED
• How does setting position: absolute on an element affect where it appears on the page?
o An element with a position absolute will appear at the TOP LEFT
It will sit at the top of its nearest ancestor that is NOT STATIC
• How do you constrain an absolutely positioned element to a containing block?
• How would you make it stop at a certain level/section?
o Position fixed would work / but there’s more to it.
o Set a position property on that element and set it to NOT STATIC