Unit 2 Section-2: Basics About CSS important questions(Exercise)
Unit 2 Section-2: Basics About CSS important questions(Exercise)
Exercise:
- 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
2. What are the ways in which you can use CSS in your HTML document?
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.
3.What are inline style sheets?
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.
4. How are internal style sheets used?
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.
5. Does the use of CSS saves time?
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.
6. How are external style sheets used?
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.
7. State difference between inline, internal & external style sheets?
Answer:

8. Why are universal and type selectors used?.
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.
9. What do we do when we have to apply style rule to a particular element only when it lies inside a particular element?
Answer: The Descendant Selectors
10. Explain the id selector.
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.
11.Can we define multiple style rules?
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.
12. What are the rules to override any style sheet?
Answer:
- 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
13. How are the color codes represented in a style sheet?
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.
14. How do we select a background attachment?
Answer: Background attachment determines whether a background image is fixed or scrolls with the rest of the page.
15. Can we set the text direction? If yes then how?
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.
16. Is RGB() property supported by all browsers?
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)”