CSS Flashcards
CSS Syntax
What are the names of the individual pieces of a CSS rule?
Declaration, selector, properties, values
CSS Syntax In CSS, how do you select elements by their class attribute?
Period symbol and name of class
CSS Syntax
In CSS, how do you select elements by their type?
Name of element
CSS Syntax
In CSS, how do you select an element by its id attribute?
The one specified after the pound or hash symbol(#) and name of id
CSS Colors
Name three different types of values you can use to specify colors in CSS.
RGB values, HEX codes, color names
CSS Box Model
What CSS properties make up the box model?
Width, height, border, margin, padding
CSS Box Model
Which CSS property pushes boxes away from each other?
Margin
CSS Box Model
Which CSS property add space between a box’s content and its border?
Padding
CSS Pseudo Classes
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(s). For example, :hover can be used to change a button’s color when the user’s pointer hovers over it.
CSS Pseudo Classes
What are CSS pseudo-classes useful for?
It helps users to interact and know if the object responded to users’ request. Change appearance of elements when a user interact with them.
CSS Fonts
Name two types of units that can be used to adjust font-size in CSS.
Pixels, percentages, ems
CSS Fonts
What CSS property controls the font used for the text inside an element?
Font-family
CSS Flexbox
What is the default flex-direction of a flex container?
Row
CSS Flexbox
What is the default flex-wrap of a flex container?
nowrap: all flex items will be on one line
CSS Layout
Why do two div elements “vertically stack” on one another by default?
Because div is a block-level element where it starts on a new line and has a full-width
CSS Layout
What is the default flex-direction of an element with display: flex?
Row
CSS Positioning
What is the default value for the position property of HTML elements?
static
CSS Positioning
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
Does not affect document flow.
CSS Positioning
How does setting position: relative on an element affect where it appears on the page?
Does allow us to move elements on the page
-The offset does not affect the position of any other elements, thus the space given for the element in the page layout is the same as if position were static.
CSS Positioning
How does setting position: absolute on an element affect document flow?
When the position property is given a value of absolute 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)
CSS Positioning
How does setting position: absolute on an element affect where it appears on the page?
An absolutely positioned element no longer exists in the normal document flow. Instead, it sits on its own layer separate from everything else.
CSS Positioning
How do you constrain an absolutely positioned element to a containing block?
Set it to non static position property
CSS Positioning
What are the four box offset properties?
-top, bottom, left, right
CSS-Cascade
What are the four components of “the Cascade”.
Source order, inheritance, specificity, !important
CSS-Cascade
What does the term “source order” mean with respect to CSS?
Source order is, simply put, the order that your CSS rules are written in your stylesheet. The styling provided for an element last in your stylesheet is the styling that will ultimately take effect
CSS-Cascade
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Inheritance is the process by which certain CSS properties on a child HTML element can receive value from a parent element if no CSS for that property is directly declared on the child element.
CSS-Cascade
List the three selector types in order of increasing specificity.
Type selector e.g (h1) and psuedo-elements (e.g ::before). Class selectors (e.g. .example), attribute selectors (e.g. [type=”radio”] and pseudo-classes(e.g. :hover). ID selectors (e.g. #example).
CSS-Cascade
Why is using !important considered bad practice?
It makes debugging more difficult by breaking the natural cascading in your stylesheets. The only way to override !important is to use other !important or use JavaScript to remove it.
CSS-Transforms
What does the transform property do?
The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.
Manipulate the way it looks
CSS-Transforms
Give four examples of CSS transform functions.
translateY(), translateX(), skew(), roate(), scale()
CSS-Transitions
The transition property is shorthand for which four CSS properties?
Transition-property, transition-duration, transition-timing-function and transition-delay
CSS-Media-Queries
Give two examples of media features that you can query in an @media rule.
Min-width, max-width
CSS-Media-Queries
Which HTML meta tag is used in mobile-responsive web pages?
Viewport meta tag
CSS-Responsive-layout
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.
- breakpoint is used when a certain style needs to be applied to a media query.
- Point where media query activates or is introduced
CSS-Responsive-layout 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?
We don’t know how big user’s screen will be so the percentage can define a size as relative to an element’s parent object. Percentage of that content would fill the viewport.
CSS-Responsive-layout
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?
CSS cascade that the bottom CSS applied first.