This section contains carefully selected MCQs and Previous Year Questions with explanations to help students understand concepts and prepare effectively for examinations, interviews, and competitive tests.
Q: 1Which CSS property can provide to add an effect when changing from one style to another, without using flash animations or JavaScript?
Option B
The CSS transition property allows you to add smooth effects when changing from one style to another without using flash animations or JavaScript. Transitions enhance user experience by providing visually appealing animations with minimal effort and without complex scripting.
It provides control over the duration, timing function, and delay of the change, enabling smooth gradual changes, such as fading colors, resizing elements, or moving components when a user interacts with a page.
button {
background-color: yellow;
transition: background-color 1s ease;
}
button:hover {
background-color: green;
}In this example, when the user hovers over the button, the background color smoothly changes from yellow to green in 1 seconds.
Q: 2Which of the following category of style sheet can be used to change the look of an entire website, by changing one file (CSS)?
Option C
CSS (Cascading Style Sheets) is used to control the appearance and presentation of HTML web pages, including colors, fonts, spacing, borders, sizes, layouts, and positioning.
When a website contains multiple HTML pages, it is often desirable to maintain a consistent design across all pages.
External CSS is particularly useful for this purpose because the CSS rules are stored in a separate .css file, and multiple HTML pages can link to the same file.
Q: 3Which of the following is NOT true about Cascading Style Sheets (CSS)?
Option D
CSS (Cascading Style Sheets) is used to control the presentation and layout of HTML documents. It separates content (HTML) from design (CSS), making web pages easier to manage and maintain.
| Statement | True / False | Explanation |
|---|---|---|
| CSS can control the layout of multiple web pages. | True | One external CSS file can be linked to many HTML pages. |
| CSS supports style formatting in HTML pages. | True | CSS is specifically designed for styling HTML elements. |
| Style definitions can be saved in an external CSS file. | True | External CSS files (.css) are commonly used. |
| Only one CSS can be used in a HTML file. | False | Multiple CSS files can be linked in one HTML document. |
CSS can be applied in three ways:
1. Inline CSS.
2. Internal CSS.
3. External CSS.
The term “Cascading” means:
Q: 4Which of the following category of CSS is defined in the <head> section of an HTML page, within a <style> element?
Option B
CSS (Cascading Style Sheets) is used to control the appearance and presentation of HTML elements, such as their colors, fonts, spacing, borders, sizes, and positioning. CSS can generally be applied to an HTML document in three ways:
| Types of CSS | Description | Example | Scope |
|---|---|---|---|
| Inline CSS | Written directly inside the style attribute of an HTML element. | <p style="color:red;">Text</p> | Usually affects one specific element. |
| Internal CSS | Written inside a <style> element, normally placed in the <head> section of the HTML document. | <style> p { color:red; } </style> | Usually affects elements within that HTML page. |
| External CSS | Written in a separate .css file and connected to the HTML document using the <link> element. | <link rel="stylesheet" href="mystyle.css"> | Can be shared across multiple HTML pages. |
Q: 5Which of the following is an advantage of using a separate CSS file in HTML?
Option D
In web development, using a separate CSS (Cascading Style Sheets) file helps in maintaining better structure and efficiency. It separates the design (CSS) from the content (HTML), which makes the code cleaner and easier to manage.
A separate CSS file allows developers to modify styles in one place, making content management easier.
It also helps in creating responsive designs for different devices like mobiles and tablets.
Additionally, CSS files are cached by the browser, which reduces server load and improves page loading speed.
You have reached the end of this topic. Continue learning with the next topic below.
Thank you so much for taking the time to read my Computer Science MCQs section carefully. Your support and interest mean a lot, and I truly appreciate you being part of this journey. Stay connected for more insights and updates! If you'd like to explore more tutorials and insights, check out my YouTube channel.
Don’t forget to subscribe and stay connected for future updates.