HTML & CSS- part 10 Flashcards

1
Q

How do you comment in CSS?

A

/* */

This also works with multi-line comments in javascript. (Single line comments in JS would be //)

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

How do you comment in HTML?

A

<!– comment goes here –> (Two dashes with no space in between)

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

What is the first thing to know about HTML layout?

A

It’s always a collection of invisible, nested boxes

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

What are the usual “boxes” in a layout?

A

The biggest box is <html></html>
The biggest box that you can style is <body></body>
The next biggest box (probably) is <div>
Then you have <p>, <a>, <span> and everything else.</span></a>

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

What are some of the big parts of almost every webpage?

A

Header
Footer
Nav bar
Side bar
Main content

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

How do you create sections like the nav bar and the header?

A

<div id=”nav_bar”>…</div>
<div id=”header”>…</div>

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

Which kinds of formats take precedence?

A

Essentially, the smaller, more precise elements overrule the bigger ones.
class, ID overrule general rules
<p>, <h1> etc. overrule <div> rules
<div> formatting overrules <body> rules.

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

What is the most important function of <div>?

A

Layout positioning

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

What is a <div> width based on?

A

Divs inherit their width from their parent.

So if you code a <div> at width: 75%, then that’s 75% of their parent, not the page.

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

Why would I explicitly code the body width at 100% when it defaults to 100% automatically?

A

Because this lets other coders know that I’m accepting the browser’s default that runs the content from edge to edge in the window

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

How do you put divs side by side?

A

use float: left; and float: right;

Then after them, use clear: both;

If there are three div boxes, use float: left for the first two and float: right for the third;

Push the content in the left box to the left and the right box to the right to avoid whitespace

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

What does this mean?

position: absolute;

A

This forces the browser to place the element exactly where you want it.

Specifically: it’s positioned relative to its nearest absolute, fixed, or relative ancestor. If it doesn’t have a positioned ancestor, it’s positioned relative to the viewport

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

How do you remove whitespace from a header?

A

left: 0; the line that places the element at the 0th pixel from the left. This eliminates whitespace on the left and right.

top: 0: the line that places the element at the 0th pixel from the top

Combining these together will take a header with white space around the sides to one that doesn’t have white space:

div#header {
width: 100%
position: absolute;
top: 0;
left: 0;
background-color: #990000;
}

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

What is a viewport?

A

Viewer’s visible area of a web page.

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

What’s one drawback of pixels?

A

They don’t adapt to different sized windows

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

How do I style an h2 heading within the div whose id is “header”?

A

div#header h2 {

17
Q

What have I noticed out maring and padding with the <div>?

A

Seems like when using <div> for layout, the margin and padding are measured in percentages rather than EMs

Also margin expands the space around the image and forces the div to expand to accommodate it

18
Q

How do these behaving differently from each other when scrolling?

position: fixed; vs. position: absolute;

A

position: fixed; This one keeps your header (or anything else) from moving off the page when you scroll.

position: absolute; This one does scroll and is placed precisely where you want it.

19
Q

When coding the position of a div with directions, which comes first?

A

The left/right part comes before top/bottom
Note: **The top, right, bottom, left positioning can be used with both position: absolute; and position: fixed;

20
Q

Can the top, right, bottom, and left positioning be used with both?

position: absolute;
position: fixed;

A

Yes, the top, right, bottom, left positioning can be used with both positions: absolute; and position: fixed;