CSS Flashcards
What are the names of the individual pieces of a CSS rule?
CSS rule consist of a selector and a declaration block
In CSS, how do you select elements by their class attribute?
With .class name
In CSS, how do you select elements by their type?
You write the name of the element as the selector
In CSS, how do you select an element by its id attribute?
With #id name
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?
Border, margin, padding
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 pseudo-class is keywords that are added to a selector that specifies a special state of the selected elements
What are CSS pseudo-classes useful for?
They are useful in applying style to an element without having to additional classes
Name at least two units of type size in CSS
pixels, percentage, ems
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 - horizontal
What is the default flex-wrap of a flex container?
No wrap
What is the default value for the position property of HTML elements?
Static - Normal Flow
How does setting position: relative on an element affect document flow?
You can shift element without affecting surrounding text and document flow
How does setting position: relative on an element affect where it appears on the page?
It stays where it is unless you shift it
How does setting position: absolute on an element affect document flow?
t’s removed from the document flow
How does setting position: absolute on an element affect where it appears on the page?
Find the boundary and look for a non-static position. Appears nearest non-static parent
How do you constrain an absolutely positioned element to a containing block?
Set up non-static position
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?
Styling provided for an element last in your stylesheet gets priority
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
Through inheritance if no CSS for that property is directly declared on the child element.
List the three selector types in order of increasing specificity.
type, class, id
Why is using !important considered bad practice?
It makes debugging more difficult by breaking the natural cascading in your stylesheets
The transition property is shorthand for which four CSS properties?
shorthand property for transition-property, transition-duration, transition-timing-function, and transition-delay
What event is fired when a user places their cursor in a form control?
focus
What event is fired when a user’s cursor leaves a form control?
blur
what event is fired as a user changes the value of a form control?
input
What event is fired when a user clicks the “submit” button within a ?
submit
What does the event.preventDefault() method do?
prevents default actions
What does submitting a form without event.preventDefault() do?
Automatically load the form values
What property of a form element object contains all of the form’s control?
elements property
What property of form a control object gets and sets its value?
value property
What is one risk of writing a lot of code without checking to see if it works so far?
It’s hard to know where the error is
What is an advantage of having your console open when writing a JavaScript program?
A
Give two examples of media features that you can query in an @media rule.
max-width, min-width, height, grid, orientation, etc
Which HTML meta tag is used in mobile-responsive web pages?
viewport
What is a breakpoint in responsive Web design?
point where our styling can break or styling changes and where the media query 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?
with percentages the layout adapts to the exact dimensions of the viewport’s width.
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 cascade system.