How to

#CSS #Web Development #frontend

Basics of CSS

What is «CSS»?

CSS, Cascading Style Sheets - is a formal language for describing the visual appearance of a document written in a markup language, using it on elements of a web page to control their look and position.

The primary goal of developing CSS was to separate the description of the logical structure of a web page, which is done via HTML or other markup languages, from the description of the appearance of that web page, which is done via CSS.

Back to Table of Contents

How are comments denoted in CSS?

To indicate that text is a comment, use the syntax /* ... */

Back to Table of Contents

What is a «selector»?

A selector is a rule that selects elements in an HTML document to apply certain styles.

p {
    text-align: center;
    font-size: 20px;
}
/* p is the selector, text-align and font-size are properties, and center and 20px are values. */

Back to Table of Contents

List the main types of selectors.

Back to Table of Contents

What is a pseudo-class?

A pseudo-class defines a dynamic state of elements that changes as a result of user actions or corresponds to the current position in the document tree. Unlike a true class, a pseudo-class is not explicitly specified in HTML, but is specified in CSS using : directly after the selector.

The most well-known pseudo-classes are:

a.snowman:link {
    color: blue;
}
a.snowman:visited {
    color: purple;
}
a.snowman:active {
    color: red;
}
a.snowman:hover {
    text-decoration: none;
    color: blue;
    background-color: yellow;
}

Back to Table of Contents

What attribute selectors are there?

Back to Table of Contents

What is the difference between #my and .my?

#my is an id selector, while .my is a class selector.

Back to Table of Contents

What is the difference between margin and padding?

margin is the outer spacing, while padding is the inner spacing.

Back to Table of Contents

What is the difference between the values 0 and auto in the margin property?

In vertical margins, auto always means 0. In horizontal margins, auto means 0 only when the width property is also auto.

Back to Table of Contents

Which property sets the background color?

The background color is set with the background-color property.

Back to Table of Contents

a {
    text-decoration: none;
}

Back to Table of Contents

What is the clear property used for?

clear specifies which side of an element must not be adjacent to floating elements.

Back to Table of Contents

How to make text bold in all <p> elements?

p {
    font-weight: bold;
}

Back to Table of Contents

How to set the color red for all elements with the class red?

.red {
    color: red;
}

Back to Table of Contents

Sources

Interview Questions