MCQs Of Class 22: Introduction to HTML and CSS Integration

Rashmi Mishra
0

 

MCQs Of Class 22: Introduction to HTML and CSS Integration

MCQ 1:

Which of the following is the correct way to add a CSS rule to an HTML element?
A) <style>p { color: red; }</style>
B) <css>p { color: red; }</css>
C) <link href="styles.css">
D) <script>p { color: red; }</script>

Answer: A
Explanation: The correct way to add a CSS rule to an HTML element is by using the <style> tag in the <head> section.


MCQ 2:

What is the purpose of the id attribute in HTML?
A) To select elements in CSS
B) To identify a unique element on the page
C) To add a background color
D) To create inline elements

Answer: B
Explanation: The id attribute is used to uniquely identify an element on a page. It allows for unique styling and JavaScript targeting.


MCQ 3:

Which CSS selector is used to select an HTML element with a specific class?
A) #classname
B) .classname
C) classname
D) *classname

Answer: B
Explanation: The . (dot) is used to select elements with a specific class in CSS.


MCQ 4:

Which of the following is NOT a valid CSS color property value?
A) #FF5733
B) rgb(255, 0, 0)
C) blue
D) border-color

Answer: D
Explanation: border-color is a property, not a color value. #FF5733rgb(255, 0, 0), and blue are valid CSS color values.


MCQ 5:

What is the default value of the position property in CSS?
A) relative
B) absolute
C) static
D) fixed

Answer: C
Explanation: The default value of the position property is static, meaning elements are positioned based on the normal document flow.


MCQ 6:

Which of the following properties is used to change the font size in CSS?
A) font-size
B) font-style
C) text-align
D) font-weight

Answer: A
Explanation: The font-size property is used to change the font size of text in CSS.


MCQ 7:

Which method of CSS integration applies styles directly to individual HTML elements?
A) External CSS
B) Internal CSS
C) Inline CSS
D) Both A and B

Answer: C
Explanation: Inline CSS is used to apply styles directly to individual HTML elements using the style attribute.


MCQ 8:

Which of the following is the correct way to link an external CSS file to an HTML document?
A) <link rel="stylesheet" href="styles.css">
B) <style src="styles.css">
C) <css href="styles.css">
D) <link src="styles.css">

Answer: A
Explanation: The <link> tag is used to link external CSS files, and the rel="stylesheet" specifies the relationship.


MCQ 9:

Which CSS property is used to change the background color of an element?
A) color
B) background-color
C) background-image
D) color-background

Answer: B
Explanation: The background-color property is used to set the background color of an element.


MCQ 10:

Which tag is used to define an internal CSS style in an HTML document?
A) <style>
B) <script>
C) <css>
D) <head>

Answer: A
Explanation: The <style> tag is used to define internal CSS within an HTML document, typically placed inside the <head> section.


MCQ 11:

What is the correct syntax for changing the font color of a paragraph to blue using CSS?
A) p { color: blue; }
B) color: p blue;
C) p: color blue;
D) p { text-color: blue; }

Answer: A
Explanation: The correct syntax for changing the font color of a paragraph is p { color: blue; }.


MCQ 12:

Which of the following selectors targets an HTML element with a specific id in CSS?
A) .idname
B) #idname
C) idname
D) *idname

Answer: B
Explanation: The # (hash) symbol is used to target an element with a specific id in CSS.


MCQ 13:

Which property is used to change the spacing between lines of text in CSS?
A) letter-spacing
B) line-height
C) word-spacing
D) text-spacing

Answer: B
Explanation: The line-height property is used to adjust the space between lines of text.


MCQ 14:

How can you select all paragraphs in an HTML document using CSS?
A) p {}
B) .p {}
C) #p {}
D) *p {}

Answer: A
Explanation: The p {} selector targets all <p> elements in the HTML document.


MCQ 15:

What does the display: none property do in CSS?
A) Hides the element but keeps it in the document flow
B) Removes the element from the document flow entirely
C) Makes the element invisible but still takes up space
D) Makes the element's text hidden

Answer: B
Explanation: The display: none property removes the element from the document flow entirely, so it no longer takes up space.


MCQ 16:

What is the correct syntax for adding a comment in CSS?
A) <!-- This is a comment -->
B) // This is a comment
C) /* This is a comment */
D) # This is a comment

Answer: C
Explanation: The correct syntax for comments in CSS is /* This is a comment */.


MCQ 17:

How do you make an HTML element's text bold using CSS?
A) text-weight: bold;
B) font-weight: bold;
C) font-style: bold;
D) font-family: bold;

Answer: B
Explanation: The font-weight property is used to make text bold in CSS.


MCQ 18:

Which of the following is the correct syntax for using a CSS class selector?
A) #class-name {}
B) .class-name {}
C) class-name {}
D) *class-name {}

Answer: B
Explanation: The . (dot) is used to select elements with a specific class in CSS.


MCQ 19:

What does the margin property in CSS do?
A) Creates space inside an element
B) Creates space between two elements
C) Changes the color of the element
D) Aligns the content of an element

Answer: B
Explanation: The margin property creates space outside an element, between it and other elements.


MCQ 20:

Which of the following is the correct way to apply CSS using an external file?
A) <link href="styles.css">
B) <style src="styles.css">
C) <link rel="stylesheet" href="styles.css">
D) <css src="styles.css">

Answer: C
Explanation: The <link> tag with rel="stylesheet" is the correct way to apply an external CSS file.


MCQ 21:

How do you change the text alignment of an HTML element to the center using CSS?
A) text-align: center;
B) text-align: middle;
C) align-text: center;
D) center-align: true;

Answer: A
Explanation: The text-align: center; property is used to center-align the text within an element.


MCQ 22:

What is the correct CSS syntax for changing the background color of a div element to red?
A) div { background-color: red; }
B) div { color: red; background: red; }
C) div { color: red; background-color: red; }
D) div { background: red color; }

Answer: A
Explanation: The correct CSS syntax to change the background color of a div is div { background-color: red; }.


MCQ 23:

Which of the following is a valid CSS border shorthand?
A) border: 1px solid blue;
B) border: 1px dashed;
C) border: solid 1px blue;
D) border: blue 1px solid;

Answer: A
Explanation: The correct syntax for a CSS border shorthand is border: width style color;.


MCQ 24:

Which HTML element is used to define an internal CSS style?
A) <link>
B) <style>
C) <script>
D) <css>

Answer: B
Explanation: The <style> tag is used to define internal CSS in an HTML document.


MCQ 25:

Which of the following is a valid CSS comment?
A) <!-- This is a comment -->
B) // This is a comment
C) /* This is a comment */
D) # This is a comment

Answer: C
Explanation: CSS comments are enclosed in /* comment */.


MCQ 26:

Which of the following CSS properties is used to control the text color of an element?
A) color
B) background-color
C) font-color
D) text-color

Answer: A
Explanation: The color property is used to control the text color of an element.


MCQ 27:

What is the default value of the display property in CSS?
A) block
B) inline
C) none
D) static

Answer: A
Explanation: By default, most elements have display: block unless specified otherwise.


MCQ 28:

Which of the following properties is used to set the space between words in CSS?
A) letter-spacing
B) line-height
C) word-spacing
D) text-spacing

Answer: C
Explanation: The word-spacing property is used to set the space between words.


MCQ 29:

Which of the following is a valid HTML5 doctype declaration?
A) <!DOCTYPE html>
B) <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 5.0//EN">
C) <!DOCTYPE HTML 5>
D) <!DOCTYPE HTML5>

Answer: A
Explanation: The correct and simplified doctype declaration for HTML5 is <!DOCTYPE html>.


MCQ 30:

What does the float property in CSS do?
A) Removes an element from the document flow
B) Floats an element to the left or right of its container
C) Aligns the text in a paragraph
D) Changes the layout of elements

Answer: B
Explanation: The float property in CSS is used to float an element to the left or right, allowing content to flow around it.


These MCQs can be continued for 50 questions by following a similar pattern, covering different aspects of HTML and CSS integration. The explanations will ensure that students understand the core concepts of CSS and HTML styling.

You said:

rest

ChatGPT said:

ChatGPT

Here are the remaining 20 multiple-choice questions (MCQs) based on HTML and CSS concepts, with detailed explanations:


MCQ 31:

Which of the following properties is used to set the width of an element in CSS?
A) width
B) height
C) border-width
D) padding

Answer: A
Explanation: The width property in CSS is used to define the width of an element.


MCQ 32:

Which CSS property is used to set the size of the text?
A) text-size
B) font-size
C) size
D) text-height

Answer: B
Explanation: The font-size property is used to set the size of the text in CSS.


MCQ 33:

Which of the following is the correct syntax for adding a background image in CSS?
A) background-image: url('image.jpg');
B) background: image('image.jpg');
C) background: url('image.jpg');
D) bg-image: url('image.jpg');

Answer: A
Explanation: The correct syntax for adding a background image is background-image: url('image.jpg');.


MCQ 34:

Which of the following tags is used to define a hyperlink in HTML?
A) <link>
B) <a>
C) <href>
D) <hyperlink>

Answer: B
Explanation: The <a> tag is used to define a hyperlink in HTML.


MCQ 35:

Which of the following is a valid HTML tag for creating an unordered list?
A) <ul>
B) <ol>
C) <list>
D) <ulist>

Answer: A
Explanation: The <ul> tag is used to create an unordered list in HTML.


MCQ 36:

Which of the following properties is used to change the font style in CSS?
A) font-style
B) font-weight
C) text-decoration
D) font-family

Answer: A
Explanation: The font-style property is used to set the style of the font (e.g., italic, normal).


MCQ 37:

Which HTML tag is used to create a table?
A) <table>
B) <td>
C) <th>
D) <tr>

Answer: A
Explanation: The <table> tag is used to create a table in HTML.


MCQ 38:

Which of the following properties is used to control the alignment of an element in CSS?
A) text-align
B) align
C) vertical-align
D) align-items

Answer: A
Explanation: The text-align property is used to align text inside an element (left, center, right).


MCQ 39:

Which of the following HTML tags is used to insert an image into a webpage?
A) <src>
B) <image>
C) <img>
D) <picture>

Answer: C
Explanation: The <img> tag is used to insert an image into a webpage in HTML.


MCQ 40:

Which of the following properties in CSS is used to create space between the element's content and its border?
A) padding
B) margin
C) border-spacing
D) width

Answer: A
Explanation: The padding property creates space between the element's content and its border.


MCQ 41:

Which of the following is the correct syntax for applying a CSS rule to a class named "button"?
A) #button {}
B) .button {}
C) button {}
D) *button {}

Answer: B
Explanation: To apply a CSS rule to a class named "button", use .button {}.


MCQ 42:

What does the position: absolute; property do in CSS?
A) Positions an element relative to its parent element
B) Positions an element based on the document's flow
C) Positions an element at the top-left corner of the page
D) Positions an element relative to the viewport

Answer: A
Explanation: position: absolute; positions an element relative to its nearest positioned ancestor (non-static).


MCQ 43:

Which of the following CSS properties controls the space between content and the border of an element?
A) padding
B) margin
C) border-radius
D) width

Answer: A
Explanation: The padding property controls the space between the content of an element and its border.


MCQ 44:

Which of the following is the correct syntax for including a comment in an HTML document?
A) <!-- This is a comment -->
B) // This is a comment
C) /* This is a comment */
D) # This is a comment

Answer: A
Explanation: The correct syntax for HTML comments is <!-- comment -->.


MCQ 45:

Which of the following properties is used to set the spacing between elements in a flex container?
A) gap
B) space-between
C) align-items
D) justify-content

Answer: A
Explanation: The gap property is used to set the spacing between elements in a flex container in CSS.


MCQ 46:

How do you specify the font family of an element in CSS?
A) font: Arial, sans-serif;
B) font-family: Arial;
C) font-type: Arial;
D) text-font: Arial;

Answer: B
Explanation: The font-family property is used to specify the font of an element in CSS.


MCQ 47:

Which of the following is used to specify the number of columns in a CSS grid layout?
A) columns
B) column-count
C) grid-template-columns
D) column-width

Answer: C
Explanation: The grid-template-columns property specifies the number of columns and their sizes in a CSS grid layout.


MCQ 48:

Which of the following HTML tags is used to create a definition list?
A) <dl>
B) <ul>
C) <ol>
D) <list>

Answer: A
Explanation: The <dl> tag is used to create a definition list in HTML.


MCQ 49:

Which CSS property is used to make text italic?
A) font-style
B) text-decoration
C) font-weight
D) text-transform

Answer: A
Explanation: The font-style property is used to set the font to italic.


MCQ 50:

Which of the following is the correct way to apply a style to a class called "menu" in an external CSS file?
A) .menu {}
B) #menu {}
C) menu {}
D) *menu {}

Answer: A
Explanation: To apply a style to a class called "menu", use .menu {}.


Tags

Post a Comment

0Comments

Post a Comment (0)