Html & CSS Flashcards

1
Q

What is SVG?

A

“SVG” stands for “Scalable Vector Graphics”.

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

What is XML?

A

XML (aka, “Extensible Markup Language”) is an HTML-like syntax which is used for lots of things, from APIs, to RSS, to spreadsheet and word editor software.

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

What is a binary file?

A

A binary file is a computer file that is not a text file.[1] The term “binary file” is often used as a term meaning “non-text file”.[2] Many binary file formats contain parts that can be interpreted as text; for example, some computer document files containing formatted text, such as older Microsoft Word document files, contain the text of the document but also contain formatting information in binary form.[2]

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

What is the xmlns attribute?

A

xmlns stands for “XML NameSpace”. This specifies what dialect of XML you’re using. In our case, that dialect is the SVG language spec. Without it, some browsers will not render your image or will render it incorrectly.

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

What are some situations where you wouldn’t want to use SVG?

A

They are extremely inefficient at storing complex images. If your image is supposed to be photo-realistic, or it has fine detail or texture (“grunge textures” are a great example), then SVGs are the wrong tool for the job.

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

What are the benefits of “inlining” your SVGs? What are the drawbacks?

A

SVG’s properties will be visible to your code, which will allow you to alter the image dynamically via CSS or JavaScript.

some serious drawbacks: it makes your code harder to read, makes your page less cacheable, and if it’s a large SVG it might delay the rest of your HTML from loading.

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

How to remove the extra spacing in a table between the first row and the rest?

A

table {
border-collapse: collapse;
}

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

How to add padding to the data in the table cell ?

A

td, th {
border: 1px solid #999;
padding: 0.5rem;
text-align: left;
}

Note that there’s always only td, th in a table

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

HTML table
How to provide common styling to columns?

A

HTML has a method of defining styling information for an entire column of data all in one place — the <col> and <colgroup> elements.

These exist because it can be a bit annoying and inefficient having to specify styling on columns — you generally have to specify your styling information on every <td> or <th> in the column, or use a complex selector such as :nth-child.

Styling columns like this is limited to a few properties: border, background, width, and visibility. To set other properties you’ll have to either style every <td> or <th> in the column, or use a complex selector such as :nth-child.

Without col, have to style on the td/th:

<table>
<tr>
<th>Data 1</th>
<th>Data 2</th>
</tr>


Instead col elements are specified in a colgroup container

<table>
<colgroup>
<col></col>
<col></col>
</colgroup>
</table></table>

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

Why would you want a CSS reset?

A

To fix the problems with default styles on different browsers

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

CSS: What are absolute units?

A

Absolute units are those that are the same in any context.
px is an absolute unit because the size of a pixel doesn’t change relative to anything else on the page. In fact, px is the only absolute unit you should be using for web projects. The rest of them make more sense in a print setting because they are related to physical units such as in (inch) and cm (centimeter).

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

What are some instances where you might want to use vh and vw?

A

Viewport units
The units vh and vw relate to the size of the viewport. Specifically, 1vh is equal to 1% of the viewport height and 1vw is equal to 1% of the viewport width. These can be useful any time you want something to be sized relative to the viewport, examples including full-height heroes, full-screen app-like interfaces.

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

What is em?
If the parent font-size is 16px, what is 1em ?

A

The em is a relative unit that refers to the font-size of the parent’s element. So, if a parent’s font-size is 16px, then 1em would be 16px and 2em would be 32px. An important thing to realize with em is that if the font-size of an element changes, so does the value of em. So, if you set some element’s font size to 2em, and one of its children is also 2em, the calculated value of those 2 font-sizes will not be the same. The child will be double the size of the parent.

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

What is rem?

A

A rem is very similar to an em except that instead of always referring to an element’s parent, it always refers to the font size of the root HTML element.
So, for example, if a parent and child both get 2rem, the calculated value will be the same.

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

What is viewport width (vw)?

A

Viewport Width (vw) – A percentage of the full viewport width. 10vw will resolve to 10% of the current viewport width, or 48px on a phone that is 480px wide.

The difference between % and vw is most similar to the difference between em and rem. A % length is relative to local context (containing element) width, while a vw length is relative to the full width of the browser window.

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

What is viewport Height?

A

Viewport Height (vh) – A percentage of the full viewport height. 10vh will resolve to 10% of the current viewport height.

17
Q

What is Viewport Minimum (vmin)?

A

Viewport Minimum (vmin) – A percentage of the viewport width or height, whichever is smaller. 10vmin will resolve to 10% of the current viewport width in portrait orientations, and 10% of the viewport height on landscape orientations.

18
Q

What is Viewport Maximum (vmax)?

A

Viewport Maximum (vmax) – A percentage of the viewport width or height, whichever is larger. 10vmax will resolve to 10% of the current viewport height in portrait orientations, and 10% of the viewport width on landscape orientations. Sadly, and strangely, vmax units are not yet available on Internet Explorer or Edge.

19
Q

What are the 2 ways to add fonts that are not installed on a user’s computer?

A

Web fonts
If you want to use a font that will not be available on the user’s device, you will need to import the font from an online source, either a font library or an asset on your site.

To use a font from one of these libraries, go to the website, select a font and then copy a snippet from the website to import that font from their server into your website. You’ll be given either a <link></link> tag to put in your HTML like so….

… or an @import tag that can be dropped at the top of a CSS file.

20
Q

What is the ‘system font stack’ and why would you want to use it?

A

The system font stack
If you use the font-family property to change to a font like impact or Times New Roman, and those fonts do not happen to be installed on your user’s computer, then a fallback font will be displayed.

body {
font-family: system-ui, “Segoe UI”, Roboto, Helvetica, Arial, sans-serif, “Apple Color Emoji”, “Segoe UI Emoji”, “Segoe UI Symbol”;
}

21
Q

Which property would you use to increase or decrease the space between letters in a word?

A

letter-spacing
Letter spacing does what you would expect…. it changes the space between letters in a word. This can be useful for adjusting custom fonts that you feel have too much or too little space. It can also be aesthetically pleasing in some cases, like headers.

22
Q

Which property would you use to increase or decrease the space between lines in a paragraph?

A

line-height
Line height adjusts the space between lines in wrapped text. Adding a little line-height can increase readability.

22
Q

Which property would you use to make an element transparent?

A

Opacity

23
Q

Which property would you use to make a background image tile?

A

background-repeat;

24
Q

Which property would you use to add scrollbars to an element?

A

overflow: scroll;

25
Q

Which property would you use to add a shadow behind an element?

A

box-shadow

26
Q

Which property would you use to create rounded corners on an element?

A

border-radius

27
Q

How would you use border-radius to make a circular element?

A

To create a circular element using border-radius, you need to set the border-radius property to 50% and ensure the element has equal width and height.

border-radius: 50%; /* Make it circular */

28
Q

What is the difference between the child combinator and the descendant combinator?

A

Descendant combinator, which is represented in CSS by a single space between selectors. A descendant combinator will only cause elements that match the last selector to be selected if they also have an ancestor (parent, grandparent, etc.) that matches the previous selector.
.ancestor .contents {
/* some declarations */
}
But what if we wanted to be more specific and select only the child or grand-child divs? That’s where the child combinator > comes in handy. Unlike the descendant combinator, it will only select direct children.

29
Q

How does the syntax of pseudo-classes and pseudo-elements differ?

A

pseudo-classes use one :
pseudo-elemts use two ::

30
Q

How could you select all classes that begin with thunder?

A

[class^=’thunder’] {
/* Classes are attributes too!
This will target any class that begins with ‘thunder’:
class=’thunderstorm’
class=’thundery’
*/
}

31
Q

What is the difference between static and relative positioning?

A

Static positioning is the default positioning mode of every element and properties top, right, bottom, left do not affect the position of the element.
Relative on the other hand, allow the properties top, right, bottom, left to displace the element relative to its normal (initial) position in the flow of the document.

32
Q

What is absolute positioning useful for?

A

It is useful when you need to position something at an exact point on the screen without disturbing the other elements around it.

33
Q

What is the difference between fixed and sticky positioning?

A

Fixed positioning means the element will remain in its fixed position as the page scrolls, but for sticky positioning, the element will stay come into view then stop and stay in its position until the parent container scrolls off.

34
Q

How would you declare a custom property with a name of text-color?

A

First, declare with double hyphen – and with a case sensitive, hyphen separated property name.

:root {
–text-color: red;
}

When we want to access a custom property, use the var() function and place our custom property name inside with the double hyphen –

.cool-paragraph {
–var(–text-color);
}

35
Q

How would you access a custom property with a name of background-color?

A

You can access it by using var() function as the value of a CSS property.

.cool-title {
color: var(–background-color);
}

36
Q

Where would you declare a custom property to have its scope be global and accessible by all other selectors?

A

I would declare it in the :root selector. This is essentially the same the html selector but has higher specificity.

By declaring our custom property in the :root selector, we can declare it on any valid selector since any other selector would be considered a descendant of the :root selector.

37
Q

What are CSS frameworks?

A

Frameworks like Bootstrap do a lot of the heavy lifting of packaging up commonly used CSS code for you, even icons and interactions (like menu dropdowns). They are designed to abstract away the process of coding intuitive, reusable, and responsive elements.

A CSS framework is ultimately just a bundle of CSS that you can use and access, using the classes defined by the framework. For example, many frameworks provide a class called .btn that will add all the needed styles to your buttons, without you having to write any CSS. In general, to use a framework, you need to understand how it expects you to structure your website and which classes it uses to apply its specific set of styles.

38
Q
A