MCQs on CSS Integration | HTML

Chapter 4: CSS Integration covers essential methods for incorporating CSS into HTML, including linking external stylesheets, using inline and internal styles, and understanding basic CSS selectors. Proper CSS integration is vital for creating visually appealing and well-structured websites. Below are 30 multiple-choice questions (MCQs) on these topics.

MCQs on CSS Integration

Linking External Stylesheets

  1. Which HTML tag is used to link an external CSS stylesheet to an HTML document?
    a) <style>
    b) <link>
    c) <css>
    d) <script>
  2. Where should the <link> tag be placed in an HTML document?
    a) In the <body> section
    b) In the <head> section
    c) At the end of the document
    d) It can be placed anywhere
  3. Which attribute of the <link> tag is used to specify the location of the external CSS file?
    a) src
    b) href
    c) path
    d) url
  4. What file extension is commonly used for external CSS stylesheets?
    a) .html
    b) .css
    c) .xml
    d) .js
  5. Can multiple external stylesheets be linked to a single HTML document?
    a) No, only one stylesheet can be linked
    b) Yes, but only if they are from the same directory
    c) Yes, multiple stylesheets can be linked
    d) No, external stylesheets are not allowed

Inline and Internal CSS Styles

  1. Which attribute is used to apply inline CSS to an HTML element?
    a) style
    b) class
    c) id
    d) css
  2. Where is internal CSS written in an HTML document?
    a) Inside the <body> tag
    b) Inside the <head> tag
    c) Directly inside the <html> tag
    d) After the <body> tag
  3. What is the correct syntax for writing inline CSS in an HTML element?
    a) <element style=”property: value;”>
    b) <element css=”property: value;”>
    c) <element class=”property: value;”>
    d) <element class=”value: property;”>
  4. Which of the following is the correct way to include internal CSS in the <head> section of an HTML document?
    a) <link rel=”stylesheet” href=”style.css”>
    b) <style type=”text/css”>… </style>
    c) <script>…</script>
    d) <css>…</css>
  5. Which of the following will override internal CSS?
    a) Inline CSS
    b) External CSS
    c) Internal CSS cannot be overridden
    d) None of the above

Basic CSS Selectors

  1. Which CSS selector is used to select an element by its id?
    a) .id
    b) #id
    c) *id
    d) &id
  2. What is the correct syntax to select all elements with the class name “highlight”?
    a) #highlight
    b) .highlight
    c) highlight
    d) *highlight
  3. Which CSS selector selects all elements on the page?
    a) *
    b) .all
    c) *all
    d) .everything
  4. How do you select all <p> elements inside a <div> element?
    a) div.p
    b) p div
    c) div > p
    d) div p
  5. How do you select an element by its tag name in CSS?
    a) By using a class selector
    b) By using a tag selector
    c) By using an id selector
    d) By using an attribute selector

Combinations of Selectors

  1. Which selector is used to select all elements that are children of a specific element?
    a) >
    b) +
    c) ~
    d) &
  2. What does the selector “div p” represent in CSS?
    a) All <p> elements inside a <div>
    b) All <div> elements inside a <p>
    c) A <div> element that directly follows a <p>
    d) A <p> element directly inside a <div>
  3. Which selector is used to select the first <li> element in every <ul>?
    a) ul li
    b) ulli
    c) ul > li
    d) ul li:first-child
  4. How can you select a specific element with a specific class and id at the same time?
    a) .class#id
    b) #id.class
    c) .class#id
    d) .class #id
  5. What is the syntax for selecting all <a> tags that are inside a <div> tag?
    a) div a
    b) div > a
    c) a div
    d) a div >

CSS Specificity and Cascade

  1. What determines which CSS rule is applied when multiple rules match the same element?
    a) The order of the rules
    b) The specificity of the selector
    c) The number of stylesheets
    d) The size of the element
  2. Which of the following has the highest specificity in CSS?
    a) Type selector
    b) Class selector
    c) ID selector
    d) Universal selector
  3. How is the “cascading” effect of CSS rules applied when there are conflicting styles?
    a) The last declared rule wins
    b) The first declared rule wins
    c) The rule with the highest specificity wins
    d) Cascading does not affect CSS
  4. What is the default value of the “position” property in CSS?
    a) absolute
    b) relative
    c) fixed
    d) static
  5. Which property is used to set the background color of an element in CSS?
    a) background-color
    b) color
    c) bg-color
    d) background-image

Advanced Selectors

  1. How do you select all <input> elements of type “text” in CSS?
    a) input[type=”text”]
    b) input(text)
    c) input[type=text]
    d) input.text
  2. What does the selector “p + p” select in CSS?
    a) All <p> elements
    b) All <p> elements after another <p>
    c) The first <p> element
    d) The last <p> element
  3. How do you select all elements that are not <p> elements?
    a)(p)
    b)(p)
    c)(p)
    d) *(p)

Answer Key

QnoAnswer
1b) <link>
2b) In the <head> section
3b) href
4b) .css
5c) Yes, multiple stylesheets can be linked
6a) style
7b) Inside the <head> tag
8a) <element style=”property: value;”>
9b) <style type=”text/css”>… </style>
10a) Inline CSS
11b) #id
12b) .highlight
13a) *
14d) div p
15b) By using a tag selector
16a) >
17a) All <p> elements inside a <div>
18a) ul li
19c) .class#id
20a) div a
21b) The specificity of the selector
22c) ID selector
23c) The rule with the highest specificity wins
24d) static
25a) background-color
26a) input[type=”text”]
27b) All <p> elements after another <p>
28a)(p)
29
30

Use a Blank Sheet, Note your Answers and Finally tally with our answer at last. Give Yourself Score.

X
error: Content is protected !!
Scroll to Top