CSS Flashcards
(56 cards)
What does CSS stand for?
Cascading Style Sheets.
What is the purpose of CSS?
To style and layout HTML elements.
What is the difference between class and ID selectors?
ID is unique (#id
), class can be reused (.class
).
What is the difference between inline, internal, and external CSS?
Inline is in the tag, internal is in <style>, external is in a separate .css file.</style>
What is specificity in CSS?
The rules that determine which CSS rule is applied.
What is the universal selector?
*
– it selects all elements.
What does the >
selector do?
Selects direct child elements.
What does the +
selector do?
Selects the next sibling element.
What does the ~
selector do?
Selects all subsequent siblings.
What is an attribute selector?
Selects elements based on attributes, e.g., [type='text']
.
What are the parts of the CSS box model?
Content, padding, border, and margin.
What does box-sizing: border-box
do?
Includes padding and border in the element’s total width and height.
What is the difference between margin and padding?
Margin is space outside, padding is space inside the border.
How do you center a block element?
margin: auto
and define width.
How do you center an inline element?
Use text-align: center
on the parent.
What are the values of the position
property?
static
, relative
, absolute
, fixed
, sticky
.
What does position: absolute
mean?
Element is positioned relative to the nearest positioned ancestor.
What does position: fixed
mean?
Element stays fixed relative to the viewport.
What does position: relative
mean?
Element is positioned relative to its normal position.
What does position: sticky
do?
Element toggles between relative and fixed depending on scroll position.
What is Flexbox used for?
To layout elements in a flexible and responsive way.
What does justify-content
control?
Alignment of items on the main axis.
What does align-items
control?
Alignment of items on the cross axis.
What does flex-grow
do?
Defines the ability of a flex item to grow.