0% found this document useful (0 votes)
9 views

CSS Assignment QA

Uploaded by

aashu2130raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CSS Assignment QA

Uploaded by

aashu2130raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CSS Assignment Questions and Answers

Q: Why are CSS selectors used in HTML?

A: CSS selectors are used in HTML to target specific HTML elements for styling. They allow

developers to apply styles to HTML tags, classes, or IDs to control the appearance of elements. This

provides flexibility in managing the look and feel of a webpage, making it easier to create organized

and visually appealing websites.

Q: What are the different types of selectors in CSS?

A: CSS offers a variety of selectors, each serving a unique purpose in targeting elements:

- Universal Selector (*) : Selects all elements.

- Type Selector : Selects all elements of a specified type (e.g., div, p).

- Class Selector (.classname) : Selects elements based on the class attribute.

- ID Selector (#idname) : Selects a single element based on its ID.

- Attribute Selector : Selects elements that have a specific attribute.

- Pseudo-class Selector : Targets elements in a specific state, such as :hover or :nth-child.

- Pseudo-element Selector : Selects parts of an element, such as ::before or ::after.

Q: How do you include external fonts and apply them?

A: External fonts can be included using the @font-face rule in CSS or by linking to a font service like

Google Fonts. For example, using Google Fonts:

<link href='https://fonts.googleapis.com/css2?family=Roboto&display=swap' rel='stylesheet'>

Then apply the font using CSS:

body { font-family: 'Roboto', sans-serif; }

You might also like