CSS Flashcards
What are CSS margins?
Margins create space around elements, outside of any defined borders
How is clockwise notation used in CSS?
It is used to specify things like borders, margins and padding
What is clockwise notation in CSS?
It describes the order in which to apply styling of a particular attribute (top, right, bottom, left)
How would you move an element to the left of it’s container?
#my-element{ float: left; }
What symbol identifies a class in CSS?
.
What symbol identifies an id in CSS?
#
What casing type is used within a style element?
kebab-case
How would you specify all elements of a certain type should appear beneath a “floated” element?
element{
clear: both;
}
What is the difference between inline and block in CSS?
Inline occurs within the “line-level” (i.e. within a sentence), whereas block represents its own HTML block
What is a CSS pseudo element?
A keyword added to a selector that lets you style a specific part of the selected element
What are CSS selectors?
The “name” given within a style element that designates the element(s) to be styled (i.e. p {})
How is pseudo element syntax different from pseudo class syntax within the style tag?
Pseudo elements are prefixed with two colons whereas pseudo classes use one (:: vs :)
Where are ::before and ::after pseudo elements positioned in respect to the parent element?
Within the parent element and before (or after) the content that the parent element contains
Can CSS images have pseudo elements?
No
In CSS, how would you create a strip above and below the content of an element without using additional elements?
Use ::before and ::after pseudo elements with a display:block attribute
How would you create a CSS selector for only h3 elements that have an attribute called heading-attribute
h3[heading-attribute] {}
Using purely CSS, how would you display the value of a custom HTML attribute within the element’s displayed content?
#html-element { content: attr(custom-attr-name); }
How would you remove text wrapping in an html element?
#element { white-space: nowrap; }
What do CSS transitions do?
Make the transitions between two different states of an element (i.e. increase width using :hover)
Using pure CSS, how would you create a CSS variable?
Within a parent element, use “–variable-name: variable-value;” syntax and then refer to the variable within the children’s styling (i.e. background: –variable-name)
What are all of the transition properties?
transition, transition-delay, transition-duration, transition-property, transition-timing-function
Why should you use milliseconds as opposed to fractions of a second for transition timing in CSS?
Both are effectively the same for CSS, but JavaScript only accepts milliseconds
What is the best CSS practice for defining multiple “transition-property” properties (i.e. a rotating and color-changing element)?
transition-property: property-one, property-two;
because the “all” value can be excessively CPU heavy
In CSS, what does the transition-timing-function property do?
Specifies how the transition will be timed (does it ease in or out?)
How would you add a gradient to text using CSS?
Add the following to the text element’s styling:
background-image: INSERT_GRADIENT;
background-clip: text;
color: transparent;
What is the name for a CSS property that is taken from a parent element?
Inherited property
How do you add an animation to a CSS property?
Create the animation using “@keyframes” followed by the animation name (a.k.a. keyframes selector) and add the “animation: ANIMATION_NAME” property to the element’s CSS
In CSS, what problem do clearfixes address?
Without one, when child elements are all floated, the parent element will go to 0px and disappear from the page
What is the syntax for a CSS clearfix?
.parent-element::after { content: ""; clear: both; display: table; }
How would you get two elements to populate side-by-side?
You can use floats, CSS grid, or flexbox - float likely has the best compatibility, but flex allows for better layouts (flex syntax is “display: flex;”)
In CSS, what does “display: inline-block” do?
It causes all of the content of the styled element to display inline (if it has multiple child elements or a list, they would display alongside one another)
What are the aspects of CSS called that you use to designate a change in style (i.e. color, font-size, etc)
CSS properties