You are on page 1of 3

Self-Check Questions for Module 3: CSS Fundamentals

Selectors and Specificity:


Explain the purpose of CSS selectors and provide an example of using a class selector.
CSS selectors are used to target and style HTML elements. They allow you to select specific
elements on a web page and apply styles to them. Selectors can target elements based on their
type, attributes, relationships with other elements, and more.

How does specificity impact the application of styles in CSS?


Specificity is a key concept in CSS that determines which styles are applied to an element when
conflicting styles exist. It is a measure of how specific a selector is and is used by the browser to
decide which style rule should take precedence when multiple rules target the same element.
The more specific a selector, the higher its specificity, and the more likely it is to override styles
from less specific selectors.

Box Model and Layout:


Describe the components of the CSS box model.

The box model is a fundamental concept in web design that defines how content is displayed in
a web page. The box model consists of four parts: margin, padding, border, and content. Margin
is the space between the border and the outside of the element. It is used to create space
between elements and to prevent content from appearing too close to the edge of the page.
Padding is the space between the content and the border. It is used to create space between the
content and the border, and to give the content more room to breathe. Border is the area that
surrounds the content and padding. It is used to separate the content from other elements on
the page, and to give it a distinct appearance. Content is the actual content of the element, such
as text, images, and videos. It is surrounded by padding and border, and is displayed within the
margins. The box model is a fundamental concept in web development that describes how
HTML elements are rendered on a web page. It consists of four components: content, padding,
border, and margin.

Create a simple layout using Flexbox and explain the key properties involved.

Flexbox, short for Flexible Box Layout, is a one-dimensional layout technique that allows you to
create flexible and responsive layouts. It works by aligning items along a single axis, either
horizontally or vertically. This makes it ideal for creating layouts that need to adapt to different
screen sizes and devices. With Flexbox, you can easily align, distribute, and reorder items within
a container, making it a great choice for creating navigation menus, buttons, and other UI
elements.
Responsive Design:

 What is responsive design, and why is it important in modern web development?

Responsive design is an approach to web design and development that aims to make
web pages render well on a variety of devices and window or screen sizes. The goal of
responsive design is to provide an optimal viewing and interaction experience across
different devices, such as desktop computers, laptops, tablets, and smartphones.

Responsive design is a crucial aspect of modern web development that addresses the
diverse landscape of devices and ensures a positive user experience across all
platforms. It helps websites adapt to the dynamic nature of the digital environment and
aligns with the expectations of users and search engines.

 Implement a media query that changes the font size when the screen width is less
than 600 pixels.

body {

font-size: 16px;

@media screen and (max-width: 599px) {

body {

font-size: 14px;

Styling Text and Fonts:

 How can you change the font family and size of text using CSS?

In CSS, you can change the font family and size of text using the font-family and
font-size properties, respectively.

 What is the difference between em and rem units in CSS?

The em unit is relative to the font size of the nearest parent element with a
specified font size. If no parent element has a specified font size, it is relative to the
default font size of the browser
The rem unit is relative to the font size of the root element (the <html> element).
This makes it more predictable and easier to manage, especially in complex layouts
where nesting can lead to compounding em values.

Positioning and Display:

 Explain the difference between position: relative, position: absolute, and


position: fixed.

When you set an element's position to relative, it is positioned relative to its normal
position in the document flow.

When you set an element's position to absolute, it is positioned relative to its


nearest positioned (not static) ancestor, if any. If there is no such ancestor, it is
positioned relative to the initial containing block

When you set an element's position to fixed, it is positioned relative to the


viewport. It will remain in the same position even if the page is scrolled.

 How does the display property impact the layout of HTML elements?

The display property in CSS plays a crucial role in determining how an HTML
element should be rendered in the layout. It influences the box model, positioning,
and overall appearance of elements. Here are some common values for the display
property and how they impact the layout of HTML elements:

CSS Transitions and Animations:

 How do CSS transitions enhance the user experience, and how are they
implemented?

CSS transitions enhance the user experience by providing smooth and gradual
changes to an element's style over a specified duration. Transitions can be applied
to various CSS properties, such as color, size, position, and opacity, allowing for
more visually appealing and interactive web interfaces.

 Create a simple CSS animation for an element on hover.

You might also like