CSS Flashcards

Apply CSS to an element, page and entire site Apply element, id and class selectors Format text using CSS Design layouts using CSS

1
Q

Three (3) ways to create and use cascading styles (CSS):

A
  1. External file
  2. Document wide
  3. Inline
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Describe External file (for including CSS):

A
  • The most popular and time-efficient way to create style sheets.
  • You create an external file and then link it to any or all web pages in a site
  • When changes are needed, updates only need to be made within the style sheet, not each individual page.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe Document Wide (for including CSS):

       /*
       CSS goes here
       */
A
  • Add styles for the individual page in the section of the page.
  • These styles can then be used anywhere in the page but cannot be used globally.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe Document Wide (for including CSS):

<p></p>

A

Inline styles are used for quick additions within a tag.

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

Describe the basic selectors for applying CSS to your elements:

p {
color: purple;
}

#main {
 color: purple; 
}     

.gallery {
color: purple;
}

A
  1. Element selector. Used to change the style applied to all elements of the selected type. The following example changes the all paragraphs to purple.
  2. Id selector. Used to modify one element’s style. The following example changes only the element with an id attribute equal to “main”
3. Class selector. Used to modify multiple elements. The following example changes only the elements with class attributes equal to "gallery"
.gallery {
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

A CSS pseudo-class is a _______ added to selectors that specifies a special state of the element to be selected.

For example :hover will apply a style when the user hovers over the element specified by the selector.

A

A CSS pseudo-class is a keyword added to selectors that specifies a special state of the element to be selected.

For example :hover will apply a style when the user hovers over the element specified by the selector.

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

Pseudo-_______, together with pseudo-______, let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator

Styling links using the “____” tag pseudo-classes

A

Pseudo-classes, together with pseudo-elements, let you apply a style to an element not only in relation to the content of the document tree, but also in relation to external factors like the history of the navigator

(:visited, for example), the status of its content (like :checked on some form elements), or the position of the mouse (like :hover which lets you know if the mouse is over an element or not).

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

Styling links using the “a” tag pseudo-classes

A
/* unvisited link */
a:link {
    color: red;
}
/* visited link */
a:visited {
    color: green;
}
/* mouse over link */
a:hover {
    color: hotpink;
}
/* selected link */
a:active {
    color: blue;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe pseudo-element:

A

A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s).

For example, ::first-line can be used to change the font of the first line of a paragraph.

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

CSS styles can overwrite each other.

Describe the priority:

A
  1. Style Tags
  2. ID
  3. Class
  4. Element (p tags)

!important –> overwrites, but not good practice

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

Unlike print layouts where the shape of content is quite flexible, web designers need to think in terms of _____ and _____.

A

Unlike print layouts where the shape of content is quite flexible, web designers need to think in terms of boxes and grids.

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

The Box Model describes the relationship between the ____, _____, ____, _____, and _____.

A

The Box Model describes the relationship between the content, padding, margin, width and height.

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

______ and ______ can be applied to all sides individually.

A

Padding and margin can be applied to all sides individually.

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

box-sizing: content-box.

By default, the “_____” and “______” properties set dimensions of the content.

Therefore, the total rendered width of the box would be: ____ + ____-left + ____-right + ____-left + ____-right.

A

box-sizing: content-box.

By default, the “width” and “height” properties set dimensions of the content.

Therefore, the total rendered width of the box would be: width + padding-left + padding-right + border-left + border-right.

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

box-sizing: border-box.

The “width” and “height” properties set dimensions of the _____ and includes ______, _____ and _____ widths.

Therefore, the total effective width of the rendered box would simply be: _____.

A

box-sizing: border-box.

The “width” and “height” properties set dimensions of the box and includes content, padding and border widths.

Therefore, the total effective width of the rendered box would simply be: width.

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

Responsive web design favours the _____- box behaviour.

A

Responsive web design favours the border-box behaviour.

17
Q

Describe Basic Units of Measurement:

A

“Ems” (em)
Pixels (px)
Points (pt)
Percent (%):

18
Q

“Ems” (em):

A

“Ems” (em): The “em” is a scalable unit that is used in web document media. An em is the font-size of an element’s parent, for instance, if the font-size of a parent div is 12px, 1em is equal to 12px for a child div.

19
Q

Pixels (px): Pixels are ______-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one _____ on the computer screen (the smallest division of your screen’s resolution).

Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser.

A

Pixels (px): Pixels are fixed-size units that are used in screen media (i.e. to be read on the computer screen). One pixel is equal to one dot on the computer screen (the smallest division of your screen’s resolution).

Many web designers use pixel units in web documents in order to produce a pixel-perfect representation of their site as it is rendered in the browser.

One problem with the pixel unit is that it does not scale upward for visually-impaired readers or downward to fit mobile devices.

20
Q

Points (pt): Points are traditionally used in _____ media (anything that is to be printed on paper, etc.).

One point is equal to __/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.

A

Points (pt): Points are traditionally used in print media (anything that is to be printed on paper, etc.).

One point is equal to 1/72 of an inch. Points are much like pixels, in that they are fixed-size units and cannot scale in size.

21
Q

Percent (%): The percent unit is much like the “em” unit, save for a few fundamental differences.

First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully ______ for mobile devices and for accessibility.

A

Percent (%): The percent unit is much like the “em” unit, save for a few fundamental differences.

First and foremost, the current font-size is equal to 100% (i.e. 12pt = 100%). While using the percent unit, your text remains fully scalable for mobile devices and for accessibility.

22
Q

Reading content in an HTML document, without any JavaScript or CSS applied, naturally flows top-down and ____-to-____. When an element is taken out of flow, space that it would have normally used is ______.

A

Reading content in an HTML document, without any JavaScript or CSS applied, naturally flows top-down and left-to-right. When an element is taken out of flow, space that it would have normally used is collapsed.

23
Q

Block elements take up the entire_____ of the document and follow one after another with their inline content flowing _____ them.

A

Block elements take up the entire width of the document and follow one after another with their inline content flowing inside them.

24
Q

Margins and padding may alter the look or spacing some, but they alone do not change the _______ of the elements.

A

Margins and padding may alter the look or spacing some, but they alone do not change the positioning of the elements.

25
Q

There are a few ways to change the default positioning and interaction between elements in the top-down blob of content:

1) You can force an element to behave like a _______ type of element,
2) you can pull the item out of the _____ completely, or you can
3) pull the item to the ______ of its container and allow other items to _____ around it.

A

There are a few ways to change the default positioning and interaction between elements in the top-down blob of content:

1) You can force an element to behave like a different type of element,
2) you can pull the item out of the flow completely, or you can
3) pull the item to the side of its container and allow other items to wrap around it.

26
Q

Static is the ______ value where an element is rendered in the normal flow and not uniquely positioned.

The positioning parameters top, right, bottom, and left do not ______.

A

Static is the default value where an element is rendered in the normal flow and not uniquely positioned.

The positioning parameters top, right, bottom, and left do not apply.

27
Q

In relative positioning, an element’s position is calculated as _______, and then the offset positioning is applied _______ to this ______ position. Relative positioning does not take the element out of the normal _____, which leaves a space behind in the element’s original position.

A

In relative positioning, an element’s position is calculated as normal, and then the offset positioning is applied relative to this normal position. Relative positioning does not take the element out of the normal flow, which leaves a space behind in the element’s original position.

28
Q

A relative positioned element with box offsets set to __ (or undefined) will appear in its ______ position; however, it will create a new point of _____ for any of its _____ elements that may be positioned absolutely.

A

A relative positioned element with box offsets set to 0 (or undefined) will appear in its normal position; however, it will create a new point of origin for any of its child elements that may be positioned absolutely.

29
Q

Absolute positioning takes the element out of the _____ document flow; ______ any space it may have otherwise used; and positions it in relation to the origin point created by the last-positioned containing block.

A

Absolute positioning takes the element out of the normal document flow; collapsing any space it may have otherwise used; and positions it in relation to the origin point created by the last-positioned containing block.

30
Q

Fixed positioning is based on the _____ and not the document. The origin for fixed-positioned elements is the root _____ (). The top-left position of 0, 0 would be the top-left corner of the ______, and similarly the bottom-right position of 0, 0 is the bottom-right corner. As the name implies, fixed-positioned elements do not _____ with the rest of a document.

A

Fixed positioning is based on the viewport and not the document. The origin for fixed-positioned elements is the root node (). The top-left position of 0, 0 would be the top-left corner of the viewport, and similarly the bottom-right position of 0, 0 is the bottom-right corner. As the name implies, fixed-positioned elements do not scroll with the rest of a document.

31
Q

Because window and viewport sizes typically _____ widely (unless you are developing for a specific device or platform such as the Apple iPhone), fixed positioning is most often used for ______ elements such as toolbars or banners and not for laying out an overall web page.

A

Because window and viewport sizes typically vary widely (unless you are developing for a specific device or platform such as the Apple iPhone), fixed positioning is most often used for small elements such as toolbars or banners and not for laying out an overall web page.

32
Q

The z-index property applies to any positioned box and can be used to control the ________ of boxes from back to front. The higher the integer value, the “_____” to the viewer the element appears.

A

The z-index property applies to any positioned box and can be used to control the layering of boxes from back to front. The higher the integer value, the “closer” to the viewer the element appears.

33
Q

Think of this index as controlling the elements of a stage set in the theatre. The background elements are at the ______ position, the actors and other elements may shuffle between ___ and ____, and the foreground set pieces and the curtain are between ___ and ____ (though there is no limit to this value).

A

Think of this index as controlling the elements of a stage set in the theatre. The background elements are at the 0 position, the actors and other elements may shuffle between 1 and 20, and the foreground set pieces and the curtain are between 21 and 25 (though there is no limit to this value).

34
Q

What happens if two elements in the same stack are at an index of 11 (or 0 or auto)?

This is not a problem unless each element’s positioning ______ cause them to overlap. In this case, the element specified later in the document flow will appear on top. This index, like positioning offsets, is relative to the containing block. If one element has a z-index of 4 and another element has a z-index of 3, none of the second element’s children can ever appear “_____” the content of the former element. Must have positioning in place to use z-index (either fixed or relative); higher number always in front;

A

What happens if two elements in the same stack are at an index of 11 (or 0 or auto)?

This is not a problem unless each element’s positioning properties cause them to overlap. In this case, the element specified later in the document flow will appear on top. This index, like positioning offsets, is relative to the containing block. If one element has a z-index of 4 and another element has a z-index of 3, none of the second element’s children can ever appear “above” the content of the former element. Must have positioning in place to use z-index (either fixed or relative); higher number always in front;

35
Q

Importing allows you to import one style sheet into another. This is slightly different than the link scenario since you can import style sheets inside a linked style sheet. This would allow multiple ._ _ _ files to be imported into a main CSS file that is then linked in your html page. The only requirement is that any @import rules need to ____ ____ the rest of your style rules.

A

Importing allows you to import one style sheet into another. This is slightly different than the link scenario since you can import style sheets inside a linked style sheet. This would allow multiple .css files to be imported into a main CSS file that is then linked in your html page. The only requirement is that any @import rules need to come before the rest of your style rules:

36
Q

Inside of a linked CSS file include the following:

A

@import url(“main.css”);

@import url(“another-css-file.css”);