Unit 2 Section-2: Basics About CSS important questions(Exercise)

Unit 2 Section-2: Basics About CSS important questions(Exercise)

Unit 2 Section-2: Basics About CSS important questions(Exercise)


  1. Why do we use CSS? What are its basic advantages?

Answer: Cascading Style Sheets (CSS) describe how documents are presented on screens, Cascading Style Sheets (CSS) provide easy and effective alternatives to specify various attributes for the HTML tags. Using CSS, you can specify a number of style properties for a given HTML element. Each property has a name and a value, separated by a colon (:).

Advantages of CSS are:

CSS saves time

Easy maintenance

Superior styles to HTML

Multiple Device Compatibility

Answer: You can use CSS in three ways in your HTML document:

1. External Style Sheet – Define style sheet rules in a separate .css file and then include that file in your HTML document using HTML<link> tag.

2. Internal Style Sheet – Define style sheet rules in header section of the HTML document using <style> tag.

3. Inline Style Sheet – Define style sheet rules directly along with the HTML elements using style attribute.

Answer: An inline CSS is used to apply a unique style to a single HTML element. An inline CSS uses the style attribute of an HTML element.

Answer: An internal style sheet may be used if one single HTML page has a unique style. The internal style is defined inside the <style> element, inside the head section.

Answer: Utilizing external CSS files allows web browsers to cache the styling information, resulting in more efficient and faster page load times. This optimization greatly enhances the overall user experience, especially for returning visitors. You can write CSS once and then reuse same sheet in multiple HTML pages. You can define a style for each HTML element and apply it to as many Web pages as you want.

Answer: To apply a rule to multiple pages, an external style sheet is used. An external style sheet is a separate CSS file that can be accessed by creating a link within the head section of the webpage. Multiple webpages can use the same link to access the stylesheet.


Answer: Universal selectors are represented by the asterisk(*). It can be applied to choose any kind of HTML page element. To choose a child objects, a selector can alternatively be used after the asterisk. When we want to select every element on the page. A type selector is sometimes referred to as a tag name selector or element selector because it selects an HTML tag/element in your document. Type selectors are not case-sensitive.

Answer: The Descendant Selectors

Answer: The id selector uses the id attribute of an HTML element to select a specific element. The id of an element is unique within a page, so the id selector is used to select one unique element. To select an element with a specific id, write a hash (#) character, followed by the id of the element.

Answer: We can define multiple style rules for a single element. We can define these rules to combine multiple properties and corresponding values into a single block. Here all the property and value pairs are separated by a semicolon (;). We can keep them in a single line or multiple lines.


  • Any inline stylesheet takes the highest priority. Therefore, it will override any rule defined in <style>…</style> tags or rules defined in an external style sheet file.
  • Any rule defined in <style>…</style> tags will override rules defined in any external style sheet file.
  • Any rule defined in external style sheet file takes the lowest priority, and rules defined in this file will be applied only when above two rules are not applicable

Answer: Hexadecimal color codes are used to represent color in a style sheet. A hexadecimal color is specified with: #RRGGBB, where the RR (red), GG (green) and BB (blue). Hexadecimal integers specify the components of the color. Six hexadecimal numerals are used in place of three values between 0 and 255.

Answer: Background attachment determines whether a background image is fixed or scrolls with the rest of the page.

Answer: Yes we can set the text direction. The direction and unicode-bidi properties can be used to change the text direction of an element.

Answer: While all major browsers support RGBA, it is not supported in Internet explorer’s 6-8 versions.

Fill in the blanks:

(a) ____________ Defines style sheet rules in a separate .css file and then include that file in your HTML document using HTML tag.

Answer: External Style Sheet 

(b) The ____________ property is used to create a small-caps effect

Answer: font-variant

(c) A cascading style sheet file will have extension as __________ and it will be included in HTML files using ____________ tag.

Answer: .css , HTML tag

(d) Each property declaration is separated by a ______________ .

Answer: a colon.

One thought on “Unit 2 Section-2: Basics About CSS important questions(Exercise)”

Leave a Reply

Your email address will not be published. Required fields are marked *