Freecodecamp random quiz - CSS Flashcards

1
Q

What is the attribute you attach to a form that specifies where the form will be submitted to?

A

The “action” attribute.

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

How can you prevent a user from submitting a form without filling in certain inputs, but only using html?

A

Add a “required” attribute to the input elements that are required. The required attribute does not need a value.

< input type=”text” required >

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

Why is it considered best practice for a label to have a “for” attribute linking it to an input?

A

It allows assistive technologies to create a linked relationship between the label and the related input element.

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

Why is it considered best practice for a label to have a “for” attribute linking it to an input?

A

It allows assistive technologies to create a linked relationship between the label and the related input element.

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

How do you tell the browser what version of HTML you are using?

A

Declare the Doctype of an HTML Document.

< !DOCTYPE html >

This means HTML version 5

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

What is an attribute selector in CSS? give an example of one!

A

A way of selecting an element based on an attribute and that attributes value.

They are placed in square brackets [attr=value]

For example [type=checkbox] would be a common one to use.

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

What is the size of an em based on ?

A

An em is based on the size of an element’s font. If you use it to set the font-size property itself, it’s relative to the parent’s font-size.

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

What is CSS inheritance?

A

A style rule applied to a parent element will be inherited by its children.

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

An element is styled with 2 classes that both style the color property. What determines which style rule is applied.

< style >
.pink-text {
color: pink;
}

.blue-text{
color: blue;
}
< /style >

< h1 class=”pink-text blue-text” >Welcome< /h1 >

A

The order of the css declarations in the style sheet. The .blue-text class declaration is last so will beat pink-text, even if you swapped the class names in the element:

< h1 class=”blue-text pink-text” >Still blue< /h1 >

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

Will an id attribute CSS declaration override a class attribute CSS declaration?

A

Yes id attribute CSS declarations have higher precedence. #id beats .class

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

Do inline styles override styles in style tags and external style sheets?

A

Yes they do!

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

How many unique colours are there in the css hexidecimal system?

A

16^6 = 16, 777, 216 unique colours!

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

How many unique colours are there in the css rgb() system?

A

each colour red, green and blue has a range of 0-255 so …

256^3 = 16, 777, 216 unique colours the same as the css hexadecimal system.

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

How do you declare a CSS variable?

A

precede it with two hyphens

–main-font-color: #6739fd;

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

How do you use a custom CSS variable?

A

Use the var( ) method.

background: var(–bg-color);

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

What is the :root pseudo-class selector and what is it used for?

A

The :root element allows you to access CSS variables from any selector in the style sheet.

To make use of inheritance, CSS variables are often defined in the :root element.

:root is a pseudo-class selector that matches the root element of the document, usually the html element. By creating your variables in :root, they will be available globally and can be accessed from any other selector in the style sheet.

17
Q

Can you overwrite a global CSS variable for a specific selector?

A

yes you can. To do this just re-declare the variable again within the selector where you want the variable to have a different value.

18
Q

What arguments does the box-shadow property accept?

A
  • offset-x (how far to push the shadow horizontally from the element),
  • offset-y (how far to push the shadow vertically from the element),
  • blur-radius,
  • spread-radius
  • color
19
Q

Can you make multiple shadows in one line with the box-shadow property ?

A

Yes you can

box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);

20
Q

How would you make anchor tag text turn blue when you hover over it?

A

Using the hover pseudo-class selector.

a:hover{
color: blue;
}

21
Q

What is the CSS box model?

A

CSS treats each HTML element as its own box, which is usually referred to as the CSS Box Model

22
Q

How do block-level and inline items behave?

A

Block-level items automatically start on a new line (think headings, paragraphs, and divs) while inline items sit within surrounding content (like images or spans).

23
Q

What does the term the normal flow of an HTML document mean and how can it be overwritten?

A

The default layout of elements is called the normal flow of a document, but CSS offers the position property to override it.

24
Q

Does changing an elements position to relative remove it from normal flow?

A

No changing an element’s position to relative does not remove it from the normal flow - other elements around it still behave as if that item were in its default position.

25
Q

What is an important nuance when using absolute positioning?

A

One nuance with absolute positioning is that it will be locked relative to its closest positioned ancestor. If you forget to add a position rule to the parent item, (this is typically done using position: relative;), the browser will keep looking up the chain and ultimately default to the body tag.

26
Q

What CSS property lets you scale up or down an elements size?

A
transform: scale(2)
// this will double an elements size;
27
Q

What CSS property lets you scale, move, rotate and skew your elements?

A

The transform property has a variety of functions that let you scale, move, rotate, skew, etc., your elements.

28
Q

How do you make an anchor tag open its link in a new window?

A

With the target=”_blank” attribute and value.

29
Q

Are all CSS properties inherited?

A

No.
For example:
Font-size is inherited.
Position is not.

30
Q

What are the before and after pseudo-elements used for ?

A

Adding content before or after the children of an element, for example:

<div>
  before text
      <h1>Heading inside the div</h1>
  after text
</div>

div::before{
content: “before text”
}

div::after{
content: “after text”
}

This might be useful to add an image/logo or some generic text to lots of elements at once.

31
Q

What is @keyframes used for?

A

Creating animations.

32
Q

What property allows us to include the padding and border in an element’s total width and height?

A

box-sizing: border-box;