CSS Flashcards

(54 cards)

1
Q

What is the purpose of CSS?

A

CSS is used to style HTML, providing control over formatting and layout of web pages.

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

Why is separating HTML and CSS beneficial?

A

It ensures consistent design across all pages and allows easy updates by editing one CSS file instead of multiple HTML files.

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

What are the three ways to reference CSS in HTML?

A

Inline style

Internal style sheet

External style sheet

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

When should inline styles be used?

A

Only when an element needs a unique style not used elsewhere, as inline styles reduce maintainability and consistency.

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

What is a drawback of internal style sheets?

A

They do not provide consistent styling across multiple pages of a site.

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

What is the benefit of using an external style sheet?

A

It allows one CSS file to style multiple HTML pages, enabling quick and consistent updates.

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

SELECTORS

What are the main categories of CSS selectors?

A

Type

Class

ID

Universal

Attribute

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

What is a type selector in CSS?

A

A selector that uses the HTML element name (e.g., p, td, h1) to apply styles.

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

What is an ID selector in CSS?

A

A selector that targets a single element with a specific id using # before the ID name.

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

What’s the difference between ID and class in CSS?

A

D is unique and used once per page.

Class can be used multiple times and elements can have multiple classes.

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

Can an element have both a class and an ID?

A

Yes, but it can have only one ID and multiple classes.

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

COMBINING SECTORS

What is a combinator in CSS?

A

defines the relationship between selectors when using CSS

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

types of combinators.

A

Child
Descendant
Adjacent sibling
General sibling.

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

Child combinator

A

allows you to select elements that are within (nested with) other
elements.

For example, suppose you want to apply a style only to h1 elements that are inside a

<div> element.

div > h1 {
color: green;
}
</div>

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

Descendant combinator

A

allows you to select elements that are within (nested with) other elements, but nested anywhere in the hierarchy of styles, not just direct children as with the child combinator.

<!DOCTYPE HTML>

<html>
<head>
<title>CSS example</title>
<style>

div p{
background:lightblue;
div>p{
background:lightgreen;
</style>
</head>
</html>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Adjacent sibling combinator

A

used to select an element that is directly after another element, not nested
within the element, but after it.

The two elements are separated by a + sign

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

General sibling combinator

A

similar to the adjacent sibling, but the sibling element does not have to directly
follow the element.

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

INHERITANCE

What is inheritance

A

Inheritance defines the way that
styles set on an element are passed down to the child elements.

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

properties that are not inherited

A

border, margin, padding,

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

APPLYING STYLES TO ELEMENTS WITH AN ATTRIBUTE VALUE

There are a number of different ways that CSS rules can be applied depending on the attributes that an element has.
What are they

A

Existence.
Equality.
Space.
Prefix.
Substring.
Suffix

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

Existence.

A

A style can be applied to those elements that simply have a certain attribute (i.e. it
exists).

For example, you could use the following CSS to style all the <a> elements that have a title attribute.
The attribute you want to select is placed in square brackets after the element, like this:</a>

a[title] {
color: red

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

Equality.

A

it may be that you want a style to apply only if the attribute is equal to a certain
value.

In which case you include the required attribute value in the selector.

a[title=”example”]{
color: green;

23
Q

Space.

A

The above method will only style the element if there is an exact match to the attribute value, but you can also set the element to be styled if the value is in a list separated by spaces
.
To do this you precede the equals sign by the ~ character. For example:

a[title~=”example”]{
color: purple;

24
Q

Prefix.

A

You can set a style based on an attribute that is prefixed (preceded) by a value using
this syntax:

a[title^=”my”]{
color: orange;

25
Substring.
You can have a substring of the attribute value for a selector using the asterisk character (*), like this: a[title*="xyz"{ color:purple;
26
Suffix
You can set a style based on an attribute that is suffixed (followed) by a value using this syntax: a[title$="example"]{ color: blue;
27
STYLING WEB PAGES What are two main ways to specify colours in CSS?
Colour names (e.g., red, blue, lightgreen) Hexadecimal notation (e.g., #245610)
28
Define hexadecimal
a numbering system using base 16 It is used in CSS for defining colours, with two hexadecimal digits used to represent the red,green and blue in a colour
29
RGB
stands for Red, Green and Blue, which are the primary colours, and which can be mixed together to make any colour
30
GRADIENTS three types of gradient you can use
Linear. Radial. Conical.
31
absolute size definition
a size that does not change and will remain constant
32
relative size definition
a size that is relative to another element such as a parent element, and will change if the size of that element also changes
33
What is a disadvantage of using absolute font sizes
The text size doesn't adjust to different screen sizes and may not be resizable in some browsers, which is problematic for visually impaired users.
34
What is the benefit of using relative font sizes (like em)?
It allows text to scale based on the user's settings and parent elements, improving accessibility.
35
STYLING FORMS Padding
Padding is extra space added inside the input box; pixels (px) are usually used for this.
36
Width:
set how wide the input box is; percentage is usually used, which sizes the box as a percentage of the width of the window.
37
What is relative positioning in CSS?
Positions an element relative to its original place in the normal flow using top, bottom, left, or right.
38
Margin:
creates space around the input box; set in pixels.
39
Floating and overlapping elements What does the float property do in CSS?
It positions an element to the left or right within its container, allowing other content to wrap around it.
39
POSITION OF ELEMENTS
40
What is absolute positioning in CSS?
Positions an element exactly where specified; it is removed from the normal flow and placed relative to the nearest positioned ancestor.
41
What is the purpose of the z-index property in CSS?
It controls the stacking order of overlapping positioned elements.
42
What is fixed positioning in CSS?
Positions an element relative to the browser window. It stays in place even when the page is scrolled.
43
CONTROLLING THE APPEARANCE OF BOX MODEL LAYOUTS Block.
This will change an inline element to be displayed as if it were a block level element so it starts on a new line rather than inline with the previous element
44
Inline.
This can be used to change the way a block element displays so it is inline.
45
Grid
Creates a grid-based layout,
46
CSS AND DIFFERENT SIZE SCREENS ways that web pages can be laid out to accommodate different screen sizes.
Fixed width layout Liquid layout.
47
Fixed width layout.
With this approach, the width of the page is set to a fixed value this does not change depending on the size of screen that the page is displayed on. Fixed width layouts are created by setting the width of elements in pixels.
48
Liquid layout.
, the width of the page elements is set as a percentage of the browser window. This means that the elements will scale, depending on the browser window size.
49
Why is responsive design important?
Because a single layout won't look or function well across devices like desktops, tablets, and mobile phones.
49
What is responsive design?
website design that responds to different screen sizes and orientations
49
RESPONSIVE DESIGN TECHNIQUES What are they
Viewport and relative measurements Grid layouts Responsive images
50
2D transforms transform property can have the following methods:
LOOK AT PAGE 190 OF TEXTBOOK
51
TRANSITIONS You can modify the way the transition is done using the transition-timing-function property which can have the following values:
1. Ease - this is the default. The effect starts slow, speeds up then slows towards the end. 2. Linear - the effect keeps a steady speed. Ease-in - the effect has a slow start and then speeds up. 3. Ease-out - the effect slows towards the end. 4. Ease-in-out- the effect has a slow start and end 5. Cubic-bezier - allows you to specify your own speed values for the effect.