5. CSS Fundamentals Flashcards

(80 cards)

1
Q

A CSS ____ consists of a selector followed by a declaration block between braces ({})

A

rule

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

A CSS ____ specifies the HTML elements to which the specific style rule applies

A

selector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A ____ contains one or more declarations separated by semicolons (;)

A

declaration block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

A CSS styling ____ is a CSS property followed by a colon (:) and the property value

A

declaration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the three ways that CSS can be applied to HTML?

A
  1. inline style (CSS declarations are placed inside of an elements “style” attribute)
  2. embedded stylesheet (places CSS rules in an HTML document’s head using a <style> element)
  3. external stylesheet (places CSS rules in a separate file that is imported into an HTML document with a <link> element)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The style declarations from a parent element ____ down and are applied to any child elements, a concept called ____

A

cascade, inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When a style conflict occurs between a parent element and a child element, which styling takes precedence?

A

The child element’s styling

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When a style conflict occurs between an embedded or external stylesheet and an inline style, which styling takes precedence?

A

The inline style

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the three different types of CSS selectors, and how are they written?

A
  1. element selector
    p { color: blue; }
  2. class selector
    .notice { color: blue; }
  3. id selector
    #byLine { color: blue }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you specify an element’s class in HTML?

A

<p class=”gr”>Moon</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you indicate that an element belongs to more than one class?

A

<span class=”highlight first”>

The space separates the two class names

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you specify an element’s id in HTML?

A

<p id=”second”>Blade Runner</p>

** An id can only be used in a single element, whereas a class can be used in multiple elements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a descendant selector? How is it written, and what does it do?

A

It matches elements that are contained in other elements.

It is written as a selector followed by a space followed by another selector.

Example:
h2 em { color: blue; }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The ____ selector matches elements based on user behavior or element metainformation

A

pseudo-class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How is a pseudo-class selector written?

A

Element followed by a colon followed by a pseudo-class

a:hover {
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can you write a selector that selects only elements that have a particular class?

A

Element followed by a period followed by the class name

span.highlight

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are some common pseudo-classes?

A

:disabled - Element is disabled

:hover - Mouse is hovering over element

:empty - Element has no child elements

:lang(language) - Element contains text in a specified language

:nth-child(n) - Element is the parent element’s nth child

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

The ____ selector matches all elements in the webpage.

A

universal

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How is the universal selector specified?

A

With an asterisk

*.highlight

The universal selector is implied when an element name is not specified.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

The ____ selector matches all listed elements to apply a style rule.

A

multiple

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How is a multiple selector specified?

A

With a comma separating selectors

ul, ol {
background-color: gray;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

The ____ selector matches any elements where the second element is a direct child of the first element.

A

child

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How is the child selector specified?

A

With a greater than sign

p > em {
background-color: yellow;
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How is the child selector (>) different from the descendant selector ( )?

A

The matching child element in the child selector must be a direct child of the matching parent element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
____ elements are elements that share the same parent element.
Sibling
26
The general sibling selector is specified with the ____ character between two selectors, and it matches the second element if the second element occurs ____ the first element and both elements are ____.
~, after, siblings h1 ~ p { border-top: 1px solid gray; } Any number of other elements can be placed between two general sibling elements
27
The ____ sibling selector, specified using a ____ character between two selectors, matches an element that ____ follows another element, where both elements have the same parent
adjacent, plus (+), immediately
28
____ are CSS selectors that match specific relationships between other selectors.
Combinators The descendant, child, adjacent sibling, and general sibling selectors are all combinators
29
What type of selector is the following? a[target="_blank"]
Attribute selector The attribute selector can be more specific by matching elements with attributes having a specific value. Ex: a[target="_blank"] attribute selector matches anchor elements with a target attribute value of _blank.
30
Which attribute selector comparator matches an element when its attribute has the exact value specified?
= [target="_blank"]
31
Which attribute selector comparator matches an element when the attribute contains the whole word specified?
~= [alt~="sad"]
32
Which attribute selector comparator matches an element when the attribute begins with a value?
^= [class^="nav"]
33
What type of selector matches parts of elements? In other words, which selector allows styles to apply to the first line or first letter of text of an element or to text that is selected by the user, or allow additional content to be inserted before or after an element?
pseudo-element selector
34
With what character(s) is the pseudo-element selector specified?
Two colons li::after { content: "<"; }
35
What are common pseudo-element specifiers?
::after - Add content after the matched element li::after { content: "<" } ::before - Add content before the matched element li::before { content: "***" } ::first-line - Match the first line of text in a block element p::first-line { color: red } ::first-letter - Match the first letter of text in a block element p::first-letter { font-size:200% } ::selection - Matches the text selected by user ::selection { background: yellow }
36
What CSS property changes the text color to a specified color value?
color
37
In what different ways can a color be specified in CSS?
- Color name (for 140 colors) - RGB color value - rgb(0, 0, 0) - Hexadecimal value - #FFFF00 - HSL color value - hsl(120, 100%, 50%)
38
What value can be added to RGB and HSL colors to allow for transparency, and what is the range for this value?
alpha, 0 to 1 (0 = fully transparent, 1 = opaque)
39
Which CSS property specifies the background color for an element?
background-color
40
Which CSS property specifies a background image for an element?
background-image
41
How are background images for elements specified?
Either with the "none" keyword or by the URL function url('URL')
42
Which CSS property specifies whether the element will be positioned to the right or left of the element's parent container, allowing text to flow around the element?
float Values for the float property: - none - Element does not float (default value) - left - Element floats to parent container's left side - right - Element floats to parent container's right side
43
Which CSS property moves elements below previously floated elements?
clear Values for the clear property: - none - Element allowed to float (default value) - left - Stop floating on parent container's left side - right - Stop floating on parent container's right side - both - Stop floating on both sides
44
Which CSS property controls the layout of the element on a webpage?
display
45
What are the values for the display property in CSS?
inline - Displays the element as an inline element, like span or a elements. block - Displays the element as a block element, like p, h1, or div elements inline-block - Displays the contents of the element as a block element, but formats the element as an inline element none - Hides the element from being displayed, like style elements list-item - Displays the contents of the element as a list item element
46
A CSS ____ is a custom CSS property that defines a value.
variable
47
How can a CSS variable be given a global scope?
by declaring the variable in the :root selector which targets the highest DOM element: the element.
48
How is a CSS variable defined?
With two dashes preceding the variable name :root { --main-color: red; --main-bg-color: yellow; }
49
How is a CSS variable accessed?
With the var() function var(--my-variable)
50
What are some of the main CSS properties for setting font properties?
font-family - (Times New Roman, serif) font-size - (120%, small,12px) font-weight - (normal, bold) font-style - (normal, italic, oblique) font-variant - (normal, small-caps) The "font" property can set several font properties at the same time: font: italic 12pt Georgia, serif;
51
A ____ in CSS is the name of a specific font, like "Times New Roman"
family name
52
If family names contain spaces, how should they be identified?
Surrounded by quotation marks
53
A ____ in CSS is a general group of fonts, like serif, sans-serif
generic family
54
What is best practice for writing the value of the font-family property?
Start with the intended font and end with a generic family font-family: Arial, Helvetica, sans-serif;
55
A ____ is a CSS feature that allows custom fonts to be downloaded to the web browser
web font
56
Fonts can be declared with either ____ sizes or ____ sizes
absolute, relative
57
What are common relative sizes?
em - Relative to the element's font size ex - x-height of the actual font ch - width of the zero rem - Relative to the root element's font size vw - 1% of the viewport's width vh - 1% of the viewport's height vmin - 1% of viewport's smaller dimension vmax - 1% of viewport's larger dimension % - Percentage of the element's font size
58
The ____ CSS property changes the horizontal alignment of text for an element
text-align
59
What are the available values for the text-align property?
left, right, center, justify
60
The ____ CSS property can add or remove properties of text like underline or strike-through
text-decoration
61
What are the different values for the text-decoration property?
overline, line-through, underline, none
62
The ____ CSS property transforms text to UPPERCASE, lowercase, or Capitalizes Initial Letters
text-transform
63
The ____ CSS property specifies the first line's indentation amount
text-indent
64
The ____ model describes the size of each HTML element as a series of nested boxes.
box
65
The name for the innermost box in the CSS box model
content
66
This box contains the content box and adds a transparent area around the content
padding
67
This box contains the padded content and adds an optionally colored area around the padding
border
68
This box contains all three boxes and adds a transparent area around the border
margin
69
Is the padding box colored or transparent?
Transparent. It will be displayed using the same color as the element's background
70
What will be the background color of the margin box?
It will be the background color of the parent element
71
For the padding and margin properties, what does it mean if 1, 2, 3, or 4 values are identified?
1: uniform thickness around the box 2: specifies top and bottom, right and left thickness 3: specifies top, right and left, and bottom thickness 4: specifies top, right, bottom, and left thickness
72
The ____ and ____ properties can change the content size of a block element's content
width, height
73
The border property combines the border ____, ____, and ____.
width, style, color
74
The vertical margins of two elements can ____.
combine or collapse The resulting margin size equals the top element's bottom margin or the bottom element's top margin, whichever is larger
75
What CSS property and value can you use to horizontally center a block element?
margin and auto margin: 0px auto;
76
What are different absolute sizes that can be used in a web page?
cm mm Q (quarter-millimeters) in pc (picas, 1/16 in) pt (1/72 in) px (1/96 in)
77
CSS ____ determines which style rules take precedence when multiple rules target the same element
specificity
78
What styling takes precedence over id, class, and element selectors?
Inline styles
79
In CSS hierarchy, what other selectors are at the same specificity level as classes?
Pseudo-classes and attribute selectors
80
What other selector has the same general level of specificity as an element selector?
Pseudo-element selector ** Although pseudo-elements have a specificity of 0, 0, 0, 1, they often combine with the specificity level of other elements or classes, giving the combination a higher precedence