All Exams  >   Class 6  >   CSS for Beginners  >   All Questions

All questions of CSS Basics - 1 for Class 6 Exam

Which selector is used to specify a rule to bind a particular unique element?
  • a)
    id
  • b)
    class
  • c)
    tag
  • d)
    both class and tag
Correct answer is option 'A'. Can you explain this answer?

Aaditya Chavan answered
HTML - ID Selector

In HTML, an ID selector is used to specify a rule that binds a particular unique element. An ID selector is denoted by the pound or hash symbol (#) followed by the unique ID name.

HTML provides several ways to select elements on a web page. These include:

1. Tag Selector: A tag selector selects all elements with the same tag name. For example, the selector "p" selects all paragraphs on a web page.

2. Class Selector: A class selector selects all elements with the same class name. For example, the selector ".myclass" selects all elements with the class name "myclass".

3. ID Selector: An ID selector selects a single element with a unique ID. For example, the selector "#myid" selects the element with the ID "myid".

ID selectors are useful when you need to target a specific element on a web page. They are unique, meaning that only one element on a page can have a particular ID. This makes it easy to select a single element using an ID selector.

To use an ID selector, simply add the ID name to the element's HTML tag, like this:

```html
This is my div.

```

Then, in your CSS file, you can target this element using the ID selector like this:

```css
#mydiv {
background-color: red;
}
```

This will set the background color of the "mydiv" element to red.

Choose the CSS property that can be used for collapsing the borders between table cells?
  • a)
    border
  • b)
    collapse-border
  • c)
    border-collapse
  • d)
    border-cell
Correct answer is option 'C'. Can you explain this answer?

Yash Sengupta answered
HTML:




Collapsing Table Borders














Cell 1 Cell 2 Cell 3
Cell 4 Cell 5 Cell 6




Explanation:
Collapsing the borders between table cells means that the borders of adjacent cells will merge to form a single border. This is done to give a cleaner and more organized look to tables. To achieve this effect, we use the CSS property 'border-collapse'.

CSS Property:
border-collapse: collapse;

This property is applied to the table element and it collapses the borders between table cells. When the border-collapse property is set to collapse, the borders of adjacent cells merge to form a single border.

In the HTML code above, we have applied the 'border-collapse' property to the table element. We have also set a border for the table cells using the 'border' property. This will create a border around each cell. However, since we have set the border-collapse property to collapse, the borders of adjacent cells will merge to form a single border.

By using this property, we can create tables that look more organized and visually appealing.

Which of the following measurement defines a measurement relative to a font’s x-height?
  • a)
    ex
  • b)
    em
  • c)
    pt
  • d)
    px
Correct answer is option 'A'. Can you explain this answer?

Amit Kumar answered
Defines a measurement relative to the height of a font in em spaces. Because an em unit is equivalent to the size of a given font, if you assign a font to 12pt, each em unit would be 12pt, thus 2em would be 24pt.

_____ has introduced text, list, box, margin, border, color, and background properties.
  • a)
    css
  • b)
    html
  • c)
    ajax
  • d)
    php
Correct answer is option 'A'. Can you explain this answer?

Tanishq Basu answered
CSS Properties

CSS (Cascading Style Sheets) is a style sheet language used for describing the presentation of a document written in HTML or XML. It defines how HTML elements should be displayed on screen, paper, or in other media. CSS has introduced various properties to style HTML elements. Some of the important CSS properties are:

1. Text Properties: CSS has introduced various text properties such as font-size, font-family, font-style, font-weight, etc. to control the appearance of text in HTML.

2. List Properties: CSS has list-style-type and list-style-image properties to control the appearance of lists in HTML.

3. Box Properties: CSS has introduced various box properties such as width, height, padding, margin, etc. to control the box model of HTML elements.

4. Border Properties: CSS has introduced various border properties such as border-width, border-style, border-color, etc. to control the appearance of borders around HTML elements.

5. Color Properties: CSS has introduced various color properties such as color, background-color, opacity, etc. to control the color of HTML elements.

6. Background Properties: CSS has introduced various background properties such as background-image, background-repeat, background-position, etc. to control the background of HTML elements.

Conclusion

In conclusion, CSS has introduced various properties to style HTML elements. Some of the important CSS properties are text, list, box, margin, border, color, and background properties. These properties have made it easier for developers to control the appearance of HTML elements and create visually appealing web pages.

Which of the following property sets the shadow for a box element?
  • a)
    shadow
  • b)
    set-shadow
  • c)
    canvas-shadow
  • d)
    box-shadow
Correct answer is option 'B'. Can you explain this answer?

The correct answer is option B) set-shadow.

Explanation:
In CSS, the property that sets the shadow for a box element is called "box-shadow". It allows you to add shadow effects to elements such as divs, images, or any other HTML element.

To use the "box-shadow" property, you can follow the syntax:
```css
box-shadow: h-offset v-offset blur spread color;
```

Let's break down the different components of this property:
- h-offset: It specifies the horizontal position of the shadow. A positive value moves the shadow to the right, and a negative value moves it to the left.
- v-offset: It specifies the vertical position of the shadow. A positive value moves the shadow downwards, and a negative value moves it upwards.
- blur: It specifies the blur radius of the shadow. A larger value creates a more blurred shadow, while a smaller value creates a sharper shadow.
- spread: It specifies the size of the shadow. A positive value increases the size, and a negative value decreases it.
- color: It specifies the color of the shadow.

Here's an example of how to use the "box-shadow" property:
```css
.box {
width: 200px;
height: 200px;
background-color: #f1f1f1;
box-shadow: 10px 10px 5px #888888;
}
```
In this example, the box element with the class "box" will have a shadow with a horizontal offset of 10px, a vertical offset of 10px, a blur radius of 5px, and a color of #888888.

Note: The other options mentioned in the question, such as "shadow", "set-shadow", and "canvas-shadow" are not valid CSS properties. The correct property to set a shadow for a box element is "box-shadow".

Which of the following selectors selects direct descendents?
  • a)
    E > F
  • b)
    E F
  • c)
    E + F
  • d)
    E ~ F
Correct answer is option 'A'. Can you explain this answer?

Suyash Datta answered
> a) E

The selector E selects all elements that match the given tag name. It does not specify any relationship between elements. To select direct descendants, we can use the child selector ">", which selects only the immediate children of the parent element. For example, to select all the direct descendants of a div element with the class "container", we can use:

```css
div.container > *
```

This selects all elements that are direct children of the div element with the class "container".

The _______ directive allows style sheets to be grouped and joined together, though some might wonder what the value of this function is given what linked styles provide.
  • a)
    <head>
  • b)
    <style>
  • c)
    <script>
  • d)
    @import
Correct answer is option 'D'. Can you explain this answer?

Amit Kumar answered
Within embedded <style> blocks, properties can be imported from an external file and expanded in place, similar to a macro. Importing can be used to include multiple style sheets. An imported style is defined within a <style> tag using @import followed optionally by a type value and a URL for the style sheet. <style> & <script> tag conatins CSS and Javascript content respectively. The metadata content is present in <head> tag.

Which of the following property assigns a graphic image to a list item?
  • a)
    list-style-type
  • b)
    list-style-image
  • c)
    list-style
  • d)
    list
Correct answer is option 'B'. Can you explain this answer?

list-style-type defines labels for a list of item. List-style property set all the properties for a list. List-style-image assign image to a list item.
Syntax:
list-style-image: url(url of image) | none

In CSS, h1 can be called as _______
  • a)
    Selector
  • b)
    Attribute
  • c)
    Value
  • d)
    Tag
Correct answer is option 'A'. Can you explain this answer?

CSS Basics: Understanding the h1 Selector

Introduction

In CSS (Cascading Style Sheets), the h1 element is a selector that is used to target and style the heading level 1 in HTML (Hypertext Markup Language) documents. The h1 element represents the most important heading on a webpage and is typically used for the main title or heading of the page.

Explanation

CSS uses selectors to target specific elements in an HTML document and apply styles to them. Selectors can target elements based on their tag name, class, ID, or other attributes. In the case of the h1 selector, it specifically targets the h1 element in the HTML structure.

Usage

To apply styles to the h1 element using CSS, you can use the h1 selector in your CSS code. Here's an example:

```css
h1 {
color: red;
font-size: 24px;
text-align: center;
}
```

In the example above, the h1 selector is used to target all h1 elements in the HTML document. The CSS properties within the curly braces ({}) specify the styles to be applied to the h1 elements. In this case, the color is set to red, the font size is set to 24 pixels, and the text alignment is set to center.

Benefits

Using the h1 selector in CSS provides several benefits:

1. Consistent Styling: By targeting the h1 element, you can ensure that all main headings on your website have a consistent style.
2. Separation of Concerns: CSS allows you to separate the styling of your HTML elements from the structure and content, making it easier to make changes or updates in the future.
3. Specificity: By using the h1 selector, you can specifically target the main headings on your webpage, allowing you to apply unique styles to them if needed.

Conclusion

The h1 selector in CSS is a powerful tool for targeting and styling the main heading on a webpage. By using this selector, you can ensure consistent styling, separate concerns, and apply specific styles to your h1 elements. Understanding how selectors work in CSS is essential for creating visually appealing and well-structured webpages.

What type of selector is used in this case?
p {line-height: 150%;}
  • a)
    class Selectors
  • b)
    element Selectors
  • c)
    id Selectors
  • d)
    none of the mentioned
Correct answer is option 'B'. Can you explain this answer?

Element Selectors

Element selectors are used to target and style specific HTML elements on a web page. They are the most basic type of selectors in CSS and are denoted by the element name followed by curly braces {} containing the CSS properties and values.

Explanation:
In the given case, the selector used is a paragraph selector (p) which is an example of an element selector.

The CSS rule applied to the paragraph selector is line-height: 150%;. This rule sets the line height of the paragraphs to 150% of the normal line height.
Line height refers to the vertical space between lines of text within a paragraph. By setting it to 150%, the space between lines is increased, making the text more spaced out.

Usage:
Element selectors are used to target specific HTML elements and apply styles to them. They are versatile and can be used to style any HTML element such as headings, paragraphs, lists, links, etc.

Example:
Here's an example of how the paragraph selector can be used in CSS:

```css
p {
color: blue;
font-size: 18px;
}
```

In this example, the paragraph selector is used to target all <p> elements on the web page. The CSS properties color and font-size are applied, making the text blue and setting the font size to 18 pixels.

Conclusion:
In summary, the given case uses an element selector (p) to target all paragraph elements on the web page and apply a line-height of 150%. Element selectors are fundamental in CSS and are used to style specific HTML elements according to the desired design and layout.

Which of the following property defines a shadow color for the right and bottom edges of a scroll bar?
  • a)
    scrollbar-darkshadow
  • b)
    scrollbar-shadow-color
  • c)
    scrollbar-darkshadow-color
  • d)
    none of the mentioned
Correct answer is option 'C'. Can you explain this answer?

Sankar Khanna answered
Understanding Scrollbar Properties
When designing user interfaces, particularly in CSS, scrollbars can be styled using various properties. One of these properties is specifically used to define the shadow color for the right and bottom edges of a scrollbar.
Key Property: scrollbar-darkshadow-color
- The correct answer to the question is option 'C': `scrollbar-darkshadow-color`.
- This property is used to set the color of the dark shadow that appears on the right and bottom edges of a scrollbar, giving it a 3D effect.
Other Options Explained
- a) scrollbar-darkshadow:
- This is not a valid CSS property. The correct form includes "color" at the end.
- b) scrollbar-shadow-color:
- This option does not exist in standard CSS. It may sound similar but does not play a role in defining scrollbar shadows.
- d) none of the mentioned:
- This option is incorrect because `scrollbar-darkshadow-color` is indeed a valid property.
Importance of scrollbar-darkshadow-color
- By using `scrollbar-darkshadow-color`, developers can enhance the visual experience of scrollbars, making them look more appealing and integrated with the overall design of the interface.
- This property is particularly useful in creating interfaces that are user-friendly and aesthetically pleasing.
In summary, `scrollbar-darkshadow-color` is the property that defines the shadow effect of scrollbars, enhancing their design and functionality in web applications.

Which of the following Color Format is a CSS’s six-digit hexadecimal format is the same as color defined in (X)HTML?
  • a)
    6-Hex Color
  • b)
    3-Hex Color
  • c)
    RGBS
  • d)
    RGBa
Correct answer is option 'A'. Can you explain this answer?

Aditi Sharma answered
The format specifies color as #rrggbb, where rr is the amount of red, gg the amount of green, and bb the amount of blue, all specified in a hexadecimal value ranging from 00 to FF.

By applying an ___________ a style can be applied to just a single tag.
  • a)
    class rule
  • b)
    element rule
  • c)
    id rule
  • d)
    none of the mentioned
Correct answer is option 'C'. Can you explain this answer?

Amit Kumar answered
By applying an id rule, a style can be applied to just a single tag. For example, if we name a tag with a unique id attribute as follows
<tag id="id-value">Affected Text</tag>

Which of the following property sets the font size of text?
  • a)
    text-size
  • b)
    font-size
  • c)
    size
  • d)
    text
Correct answer is option 'B'. Can you explain this answer?

Explanation:

font-size Property:
The font-size property in CSS is used to set the size of the text in an HTML element. It allows you to specify the size of the font using different units such as pixels, em, rem, percentages, etc.

Example:
This is a sample text with font size of 16 pixels.


Setting Font Size:
- The font-size property can be applied to various HTML elements such as headings, paragraphs, and spans.
- It can be set using absolute values like pixels or relative values like em or percentages.
- The default font size for most browsers is 16px.

Usage:
- To set the font size of text within a specific HTML element, you can use the following CSS syntax:
css
selector {
font-size: value;
}
- Here, the 'selector' can be any HTML element selector like p, h1, span, etc., and the 'value' can be specified in pixels, em, rem, percentages, etc.

Conclusion:
The correct property to set the font size of text in CSS is the font-size property. It allows you to control the size of text within HTML elements to enhance the readability and aesthetics of your web page.

_______ selectors are used to specify a group of elements.
  • a)
    id
  • b)
    class
  • c)
    tag
  • d)
    both class and tag
Correct answer is option 'B'. Can you explain this answer?

Selectors in HTML are used to select and style specific elements on a web page. There are different types of selectors used in HTML, including ID, class, and tag selectors. In this question, we are asked to identify the selector used to specify a group of elements.

Class selectors are used to specify a group of elements. They allow us to select and style multiple elements that share the same class attribute. Here's an example:

```
This is the first paragraph.

This is the second paragraph.

This is the third paragraph.

```

In this example, all three paragraphs have the same class attribute value of "intro". We can use a class selector to select and style all three paragraphs at once:

```
.intro {
font-size: 18px;
color: blue;
}
```

This CSS code will apply to all elements with the class attribute value of "intro", which in this case, are all three paragraphs.

In summary, class selectors are used to specify a group of elements that share the same class attribute value. They allow us to select and style multiple elements at once, which is useful for applying consistent styles to related elements.

In css, “color:red” can be called as ________
  • a)
    Selector
  • b)
    Rule
  • c)
    Declaration
  • d)
    Value
Correct answer is option 'C'. Can you explain this answer?

Nishanth Patel answered
CSS stands for Cascading Style Sheets. It is a style sheet language used to describe the presentation of a document written in HTML. CSS allows web designers to control the layout, colors, fonts, and other visual aspects of a webpage.

CSS uses a selector to target HTML elements and apply styles to them. Selectors can target elements by tag name, class, ID, or other attributes. Once a selector is defined, properties and values can be assigned to it to specify the desired visual style.

For example, the following CSS code sets the background color of all paragraph elements to blue:

```
p {
background-color: blue;
}
```

CSS rules can also be applied to multiple elements by using classes or IDs. Classes are defined using a dot (.) followed by the class name, while IDs are defined using a hash (#) followed by the ID name.

```
.my-class {
color: red;
}

#my-id {
font-size: 20px;
}
```

In addition to basic styling, CSS also supports more advanced features such as animations, transitions, and responsive design. It is widely used in web development to create visually appealing and user-friendly websites.

Which of the following tag is used to embed css in html page?
  • a)
    <script>
  • b)
    <style>
  • c)
    <css>
  • d)
    <!DOCTYPE html>
Correct answer is option 'B'. Can you explain this answer?

Avinash Patel answered
<style> </style> tag is used to embed CSS in HTML page, while <script> </script> is used to embed JS in HTML. <!DOCTYPE html> is HTML5 declaration.

Which of the following selectors selects siblings?
  • a)
    E.class
  • b)
    E ~ F
  • c)
    *
  • d)
    E, F, G
Correct answer is option 'B'. Can you explain this answer?

Ameya Shah answered
Selector that selects siblings:
The correct answer is option 'B': E ~ F

Explanation:
In CSS, a sibling selector is used to select elements based on their relationship to a sibling element. It allows you to select elements that share the same parent and are adjacent or follow each other in the HTML structure.

Example:
Consider the following HTML structure:

```html

Paragraph 1

Heading

Paragraph 2

Paragraph 3


```

In this example, we have a parent `
` element and multiple `` elements as siblings.

Using the sibling selector:
To select the `` elements that are siblings of the `
` element, we can use the sibling selector "~". The syntax for using the sibling selector is as follows:

```css
E ~ F
```

Here, "E" represents the first element (preceding sibling) and "F" represents the second element (following sibling) that we want to select.

Applying the sibling selector:
To select the `` elements that are siblings of the `
` element in the above example, we can use the following CSS rule:

```css
h1 ~ p {
/* CSS properties */
}
```

This rule selects all `` elements that come after the `
` element and share the same parent `
`. The selected elements will be Paragraph 2 and Paragraph 3 in this case.

Conclusion:
The correct selector for selecting siblings is option 'B': E ~ F. This selector allows you to target elements that are siblings of a specific element.

Which of the following specifies the distance between the borders of adjacent cells?
  • a)
    border-spacing-cell
  • b)
    border-width-spacing
  • c)
    border-spacing
  • d)
    cell-spacing
Correct answer is option 'C'. Can you explain this answer?

Tejas Jain answered
Understanding Border Spacing in Tables
When designing tables in HTML, it's essential to manage the space between cells effectively. One of the key properties related to this is known as "border-spacing."
What is Border Spacing?
- Border spacing is a CSS property that defines the distance between the borders of adjacent cells in a table.
- It creates a gap between each cell, enhancing readability and visual appeal.
Why is "border-spacing" the Correct Answer?
- Correct Terminology: The term "border-spacing" specifically refers to the property used in CSS to set the space between table cell borders.
- CSS Implementation: It can be applied to a table element to specify horizontal and vertical spacing. For example:
- `border-spacing: 10px;` would create a 10-pixel space between the borders of adjacent cells.
Other Options Explained
- border-spacing-cell: This is not a valid CSS property.
- border-width-spacing: This term does not exist in CSS and does not relate to cell spacing.
- cell-spacing: This was an attribute used in older HTML standards but is now deprecated in favor of CSS properties like "border-spacing."
Conclusion
Understanding the correct terminology and properties in CSS helps create well-structured and visually appealing tables. The correct answer is indeed option 'C', "border-spacing," as it accurately describes the distance between the borders of adjacent cells.

Which of the following property sets an element’s background color?
  • a)
    background-image
  • b)
    background-color
  • c)
    background-colors
  • d)
    background-position
Correct answer is option 'B'. Can you explain this answer?

Juhi Kumar answered
Understanding Background Color in CSS
When styling web pages, CSS (Cascading Style Sheets) provides various properties to customize the appearance of elements. Among these, the background color is a fundamental aspect that enhances the visual appeal of a webpage.
Correct Property: background-color
- The correct answer to the question is background-color.
- This property is specifically designed to set the background color of an HTML element.
Explanation of Other Options
- background-image:
- This property is used to set an image as the background of an element, not a color.
- background-colors:
- This is not a valid CSS property. The correct singular form is background-color.
- background-position:
- This property determines the position of a background image within an element, not the color.
Usage Example
To use the background-color property in CSS, you can write:
css
div {
background-color: blue;
}
In this example, any `
` element will have a blue background.
Conclusion
Understanding the correct properties in CSS is essential for effective web design. The background-color property is crucial for setting the background color of elements, making it an essential tool for any web developer or designer.

What will be the output of below mentioned code snippet?
p strong {background-color: yellow;}
  • a)
    Strong have yellow background
  • b)
    Strong element within a p element have a yellow background
  • c)
    Both p and strong have yellow background
  • d)
    None of the mentioned
Correct answer is option 'B'. Can you explain this answer?

Pranav Saini answered





Explanation:







HTML Code:

- The given code snippet contains CSS styling for the element within a element.
- The CSS rule sets the background color of the element to yellow.





Output:

- When this code is applied, only the element within a element will have a yellow background.
- Other elements that are not within a element will not have the yellow background.

Which of the following CSS property sets the font size of text?
  • a)
    font-size
  • b)
    text-size
  • c)
    text
  • d)
    size
Correct answer is option 'A'. Can you explain this answer?

Avinash Patel answered
CSS Syntax:
font-size: length | percentage | larger | smaller | xx-small | x-small | 
small | medium | large | x-large | xx-larger | inherit

Which of the following property defines a shadow effect for text?
  • a)
    box-shadow
  • b)
    img-shadow
  • c)
    text-shadow
  • d)
    none of the mentioned
Correct answer is option 'D'. Can you explain this answer?

The shadow effects are applied in the order specified and may overlay each other, but they will never overlay the text itself. Each shadow effect must specify a shadow offset horizontally and vertically and may optionally specify a blur radius and a shadow color.

Which of the following CSS3 Color Feature like RGB color but adds an alpha channel value to specify the opacity of the color?
  • a)
    RGB
  • b)
    RGBa
  • c)
    RGBaplha
  • d)
    AlphaRGB
Correct answer is option 'B'. Can you explain this answer?

Aditya Shah answered
An RGBa is specified via a function style rgba(r,g,b,a) value, where colors r, g, and b are specified as a decimal value from 0 to 255 or a percentage from 0 to 100%, and the alpha channel value for defining opacity is a number between 0 (fully transparent) and 1 (fully opaque). Values outside this range will be rounded up or down to fit the closest value.

Which of the following property sets a variation of the specified or default font family?
  • a)
    height
  • b)
    font-weight
  • c)
    default
  • d)
    font-variant
Correct answer is option 'D'. Can you explain this answer?

Aditya Shah answered
Syntax:
font-variant: normal | small-caps | inherit
The small-caps value sets text in smaller-size all capitals. The normal value would be used to override any inherited font-variant value. Font-weight is for increasing/decreasing weight of font. It takes values like normal, bold, lighter, and bolder.

Which of the following tag is used to linked information should be placed inside?
  • a)
    <head>
  • b)
    <html>
  • c)
    <div>
  • d)
    <body>
Correct answer is option 'A'. Can you explain this answer?

Avinash Patel answered
Linked information regarding CSS like external CSS document information is always placed in <head> tag. <body> tag contains the body of the document.

Which of the following measurement defines measurement as a percentage?
  • a)
    %
  • b)
    cm
  • c)
    em
  • d)
    in
Correct answer is option 'A'. Can you explain this answer?

Amit Kumar answered
Defines a measurement as a percentage. Percentages are denoted by a number followed by the % symbol and are always relative to another value such as length. Quite often they are used to specify some value relative to an inherited value from a parent element.

Chapter doubts & questions for CSS Basics - 1 - CSS for Beginners 2025 is part of Class 6 exam preparation. The chapters have been prepared according to the Class 6 exam syllabus. The Chapter doubts & questions, notes, tests & MCQs are made for Class 6 2025 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests here.

Chapter doubts & questions of CSS Basics - 1 - CSS for Beginners in English & Hindi are available as part of Class 6 exam. Download more important topics, notes, lectures and mock test series for Class 6 Exam by signing up for free.

CSS for Beginners

10 videos|41 docs|23 tests

Top Courses Class 6