CSS Flashcards

1
Q

Explain the CSS “box model” and the layout components that it consists of.

Provide some usage examples.

A

The CSS box model is a rectangular layout paradigm for HTML elements that consists of content, padding, border, and margin.

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

How would you select every <a> element whose href attribute value begins with “https”?</a>

A

a[href^=”https”]

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

How would you select every <a> element whose href attribute value ends with “.pdf”.</a>

A

a[href$=”.pdf”]

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

How would you select every <a> element whose href attribute value contains the substring “css”.</a>

A

a[href*=”css”]

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

How would you add automatic numbering to headers?

A
#page {
  counter-reset: heading;
}

h1:before {
content: counter(heading)”) “;
counter-increment: heading;
}

h1 {
counter-reset: subheading;
}

h2:before {
content: counter(heading)”.” counter(subheading)”) “;
counter-increment: subheading;
}

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

What is the difference between position:relative and position:absolute?

A

The word relative in position:relative means that it is “relative to itself”. If you put position:relative on an element it will not affect it’s positioning at all. It will remain exactly as it would be if you left it as the default state. At this point you are able to move the element in any direction from it’s original position using top:, right:, bottom: and left:. position:relative also introduces the ability to us z-index, which decides which elements overlap others.

If you want to place an element wherever you want it, you might use position:absolute. The first thing that happens is that the element will be removed from the flow of elements on the page. Using position:absolute you can now position the element anywhere relative to the next parent of the element that has position:relative (or absolute). You position the element using top:, right:, bottom: and left:. position:absolute also brings z-index into play.

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