CSS Flashcards

1
Q

Explain the three main ways to apply CSS styles to a web page

A

1) inline style attribute
2) style tag in head of document
3) external style sheet

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

What is CSS?

A

CSS stands for Cascading Style Sheets. CSS is used to define styles for your web pages, including the design, layout and variations in display for different devices and screen sizes.

CSS was intended to allow web professionals to separate the content and structure of a website’s code from the visual design.

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

How to use variables in Sass?

A

Think of variables as a way to store information that you want to reuse throughout your stylesheet. You can store things like colors, font stacks, or any CSS value you think you’ll want to reuse. Sass uses the $ symbol to make something a variable.

$font-stack: Helvetica, sans-serif;
$primary-color: #333;

body {
font: 100% $font-stack;
color: $primary-color;
}

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

Explain CSS sprites, and how you would implement them on a page or site.

A

CSS sprites combine multiple images into one single larger image. It is commonly used technique for icons.

Use a sprite generator that packs multiple images into one and generate the appropriate CSS for it.
Each image would have a corresponding CSS class with background-image, background-position and background-size properties defined.
To use that image, add the corresponding class to your element.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

Content - The content of the box, where text and images appear

Padding - A transparent area surrounding the content (i.e., the amount of space between the border and the content)

Border - A border surrounding the padding (if any) and content

Margin - A transparent area surrounding the border (i.e., the amount of space between the border and any neighboring elements)

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

What is a CSS rule?

A

Web browsers apply CSS rules to a document to affect how they are displayed. A CSS rule is formed from:

A set of properties, which have values set to update how the HTML content is displayed,

A selector, which selects the element(s) you want to apply the updated property values to.

A set of CSS rules contained within a stylesheet determines how a webpage should look.

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

Explain what is a @extend directive used for in Sass?

A

Using @extend lets you share a set of CSS properties from one selector to another. It helps keep your Sass very dry.

%message-shared {
  border: 1px solid #ccc;
  padding: 10px;
  color: #333;
}

.message {
@extend %message-shared;
}

.success {
@extend %message-shared;
border-color: green;
}

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

Have you played around with the new CSS Flexbox or Grid specs?

A

Yes. Flexbox is mainly meant for 1-dimensional layouts while Grid is meant for 2-dimensional layouts.

Flexbox solves many common problems in CSS, such as vertical centering of elements within a container, sticky footer, etc. Bootstrap and Bulma are based on Flexbox, and it is probably the recommended way to create layouts these days. Have tried Flexbox before but ran into some browser incompatibility issues (Safari) in using flex-grow, and I had to rewrite my code using inline-blocks and math to calculate the widths in percentages, it wasn’t a nice experience.

Grid is by far the most intuitive approach for creating grid-based layouts (it better be!) but browser support is not wide at the moment.

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

What is DOM (Document Object Model) and how is it linked to CSS?

A

The Document Object Model (DOM) is a cross-platform and language-independent application programming interface that treats an HTML, XHTML, or XML document as a tree structure wherein each node is an object representing a part of the document.

With the Document Object Model, programmers can create and build documents, navigate their structure, and add, modify, or delete elements and content. The DOM specifies interfaces which may be used to manage XML or HTML documents.

When a browser displays a document, it must combine the document’s content with its style information. The browser converts HTML and CSS into the DOM (Document Object Model). The DOM represents the document in the computer’s memory. It combines the document’s content with its style.

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

What is Sass?

A

Sass or Syntactically Awesome StyleSheets is a CSS preprocessor that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly.

A CSS preprocessor is a scripting language that extends CSS by allowing developers to write code in one language and then compile it into CSS.

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

What existing CSS frameworks have you used locally, or in production? How would you change/improve them?

A

Bootstrap - Slow release cycle. Bootstrap 4 has been in alpha for almost 2 years. Add a spinner button component, as it is widely used.

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

Describe floats and how they work

A

Float is a CSS positioning property. Floated elements remain a part of the flow of the web page. This is distinctly different than page elements that use absolute positioning. Absolutely positioned page elements are removed from the flow of the webpage.

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

What Selector Nesting in Sass is used for?

A

Sass let you nest your CSS selectors in a way that follows the same visual hierarchy of your HTML. CSS, on the other hand, doesn’t have any visual hierarchy.

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

List out the key features for Sass?

A
  • Full CSS3-compatible
  • Language extensions such as nesting, variables, and mixins
  • Many useful functions for manipulating colors and other values
  • Advanced features like control directives for libraries
    Well-formatted, customizable output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between classes and IDs in CSS?

A

IDs — Meant to be unique within the document. Can be used to identify an element when linking using a fragment identifier. Elements can only have one id attribute.

Classes — Can be reused on multiple elements within the document. Mainly for styling and targeting elements.

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

List out the data types that Sass supports

A
  • Numbers
  • Strings
  • Colors
  • Booleans
  • Null
  • Lists
  • Maps