1000 CSS MCQ (Multiple Choice Questions) - Sanfoundry

Here are 1000 MCQs on CSS (Chapterwise).

1. What is CSS? a) CSS is a style sheet language b) CSS is designed to separate the presentation and content, including layout, colors, and fonts c) CSS is the language used to style the HTML documents d) All of the mentioned View Answer Answer: d Explanation: CSS is a style sheet language that stands for Cascading Style Sheet and is used to style HTML documents. CSS is mainly designed to separate the presentation and content, including layout, colors, and fonts.

2. Which of the following tag is used to embed css in html page? a) <css> b) <!DOCTYPE html> c) <script> d) <style> View Answer Answer: d Explanation: <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.

3. Which of the following CSS selectors are used to specify a group of elements? a) tag b) id c) class d) both class and tag View Answer Answer: c Explanation: Class selectors are used to specify a group of elements. Id selector specifies a particular unique element.

4. Which of the following has introduced text, list, box, margin, border, color, and background properties? a) HTML b) PHP c) CSS d) Ajax View Answer Answer: c Explanation: CSS is a style sheet language that stands for Cascading Style Sheet. CSS has introduced text, list, box, margin, border, color, and background properties.

5. Which of the following CSS framework is used to create a responsive design? a) django b) rails c) larawell d) bootstrap View Answer Answer: d Explanation: Bootstrap is a free and open-source collection of tools for creating websites and web applications. It contains HTML- and CSS-based design templates for typography, forms, buttons, navigation and other interface components, as well as optional JavaScript extensions. It aims to ease the development of dynamic websites and web applications. advertisement advertisement

6. Which of the following CSS selector is used to specify a rule to bind a particular unique element? a) tag b) id c) class d) both class and tag View Answer Answer: b Explanation: For binding a particular unique element, id selectors are used. While for a group of elements, class selector can be used.

7. Which of the following type of HTML tag is used to define an internal style sheet? a) <script> b) <link> c) <class> d) <style> View Answer Answer: d Explanation: <style> tag is used to define an internal style sheet in HTML document.

8. Which of the following CSS property is used to make the text bold? a) text-decoration: bold b) font-weight: bold c) font-style: bold d) text-align: bold View Answer Answer: b Explanation: The font-weight property is used for setting the thickness and boldness of the font. It is used to define the weight of the text. The available weight depends on the font-family, which is used by the browser.

9. What will be the output of following CSS code snippet?

h1 {color: "green";}

a) nothings happen b) error occurs c) heading becomes dark-green d) heading becomes green View Answer Answer: a Explanation: Output of the above code snippet won’t happen as the declaration syntax is wrong. The correct declaration is : h1 { color: green; } which will yield an output. In CSS, we don’t write the value in double quotes.

10. Which of the following CSS style property is used to specify an italic text? a) style b) font c) font-style d) @font-face View Answer Answer: c Explanation: font-style property is used to specify an italic text. font-style property has three values (normal, italic & oblique).

11. What will be the output of following CSS code snippet?

h1 {color: red text-decoration: underline; font-style: italic;}

a) color: red, text-decoration: underline works b) only font-style: italic works c) color: red, text-decoration: underline and font-style: italic all works d) text-decoration: underline and font-style: italic works View Answer Answer: b Explanation: In this case, we should see the browser continue to parse the value of color as “red text-decoration: underline” before it sees a closing semicolon. The font-style property that follows would then be used. Because the color property has an illegal value, it should be ignored. advertisement

12. Which of the following are the CSS Extension Prefixes for Webkit? a) -chrome b) -web c) -o- d) -webkit View Answer Answer: d Explanation: Browser sometimes adds prefixes to non-standard CSS properties. CSS Extension prefix for Webkit is -webkit which is supported by almost all ios browsers. -o is used by opera where as -moz is used by firefox browser.

13. Which of the following is the correct syntax to link an external style sheet in the HTML file? a) <link rel=”stylesheet” href=”style.css” /> b) <link rel=”stylesheet” src=”style.css” /> c) <style rel=”stylesheet” src=”style.css” /> d) <style rel=”stylesheet” link=”style.css” /> View Answer Answer: a Explanation: HTML file must contain a reference to the external style sheet file. External style sheet files are defined within the <link> element and it should be inside the <head> section. href attribute specifies the URL of the linked resource.

14. Which of the following is the first CSS specification to become an official W3C Recommendation? a) CSS level 2 b) (X)HTML CSS c) CSS level 1 d) CSS level 2.1 View Answer Answer: c Explanation: The first CSS specification to become an official W3C Recommendation is CSS level 1, published on December 17, 1996. Håkon Wium Lie and Bert Bos are credited as the original developers.

15. Which of the following function defines a linear gradient as a CSS image? a) gradient() b) linear-gradient() c) grayscale() d) image() View Answer Answer: b Explanation: linear-gradient() function defines a linear gradient as a CSS image. Creating a linear gradient function we should define minimum of two color stops. color stops will tell the browser which colors to use in the gradients for smooth transitions. advertisement

16. Which of the following CSS property can be used to set the image as a border instead of the border style? a) background-image-source b) background-image c) border-image-source d) border-image View Answer Answer: c Explanation: The border-image-source property specifies the path to the image to be used as a border (instead of the normal border around an element).

17. Which of the following CSS property defines the different properties of all four sides of an element’s border in a single declaration? a) border-collapse b) border-width c) padding d) border View Answer Answer: b Explanation: The border-width property sets the width of an element’s four borders. This property can have from one to four values.

18. Which of the following is the correct way to apply CSS Styles? a) in an external CSS file b) inside an HTML element c) inside the <head> section of an HTML page d) all of the mentioned View Answer Answer: d Explanation: We can style the document using CSS in three different ways i.e embed, inline and external. An inline CSS means applying styles rules directly to the HTML element. In embed, we declare or write all the needed style in <style></style> tag in the head section of the HTML document. We can create an external style sheet and provide its link to the document.

19. Which of the following CSS property sets the font size of text? a) font-size b) text-size c) text d) size View Answer Answer: a Explanation: CSS Syntax:

font-size: length | percentage | larger | smaller | xx-small | x-small | small | medium | large | x-large | xx-larger | inherit

Từ khóa » Html And Css Interview Questions Mcq