True or false: An <option> element must have a value attribute.
a) True b) False
Correct Answer: b) False
Explanation: The value attribute is not required for an <option> element, although it is good practice to include it.
Question 22
Which HTML element can create a button with an image?
a) <input> b) <button> c) <form> d) <textarea>
Correct Answer: b) <button>
Explanation: The <button> element can contain images and text, making it more versatile than the <input> element.
Question 23
Which of the following are valid <input> types for entering specific types of text?
a) Email, text, search, tel b) Email, search, tel, url c) Password, email, tel, search d) Url, password, number, tel
Correct Answer: b) Email, search, tel, url
Explanation: These are the specific <input> types used to enter data in email, search, telephone, and URL formats.
Question 24
Which of the following audio formats are supported by nearly all web browsers?
a) OGG, AAC b) AAC, MP3 c) MP3, WAV d) WAV, FLAC
Correct Answer: b) AAC, MP3
Explanation: AAC and MP3 are widely supported audio formats in most web browsers.
Question 25
Which of the following is the correct HTML syntax for referring to an external style sheet?
a) <link type=”stylesheet” href=”mystyle.css”> b) <link rel=”stylesheet” href=”mystyle.css”> c) <style src=”mystyle.css”> d) <link rel=”style” href=”mystyle.css”>
Correct Answer: b) <link rel="stylesheet" href="mystyle.css">
Explanation: The correct syntax includes the rel="stylesheet" attribute in the <link> tag.
Question 26
Where in an HTML document is the correct place to refer to an external style sheet?
a) In the <head> section b) In the <body> section c) Before the <!DOCTYPE html> declaration d) At the end of the document
Correct Answer: a) In the <head> section
Explanation: External style sheets should be linked in the <head> section of an HTML document.
Question 27
Which HTML tag is used to define an internal style sheet?
a) <style> b) <link> c) <head> d) <script>
Correct Answer: a) <style>
Explanation: The <style> tag is used within the <head> section to define internal CSS.
Question 28
Which HTML attribute is used to define inline styles?
a) Css b) Style c) Class d) Id
Correct Answer: b) Style
Explanation: The style attribute is used to apply inline CSS to HTML elements.
Question 29
Which of the following is the correct CSS syntax to set text color to black for all <body> elements?
a) body {color: black;} b) body {text-color: black;} c) body {color: #000000;} d) body {font-color: black;}
Correct Answer: a) body {color: black;}
Explanation: The color property in CSS is used to set the text color.
Question 30
How do you insert a CSS comment?
a) // this is a comment b) /* this is a comment */ c) <!– this is a comment –> d) # this is a comment
Correct Answer: b) /* this is a comment */
Explanation: CSS comments are enclosed within /* and */.
Question 31
Which CSS property is used to change the background color of an element?
a) Color b) Background c) Background-color d) Bg-color
Correct Answer: c) Background-color
Explanation: The background-color property is used to set the background color of an element.
Question 32
Which property is used to add a background color to <h1> elements?
a) color b) background-color c) background d) border-color
Correct Answer: b) background-color
Explanation: The background-color property applies a background color to elements, including <h1>.
Question 33
Which CSS property is used to change the text color of an element?
a) Font-color b) Text-color c) Color d) Font-style
Correct Answer: c) Color
Explanation: The color property in CSS sets the text color of an element.
Question 34
Which CSS property controls the text size?
a) Font-size b) Text-size c) Size d) Font-weight
Correct Answer: a) Font-size
Explanation: The font-size property adjusts the size of text in an element.
Question 35
Which CSS syntax makes all <p> elements bold?
a) p {font-weight: bold;} b) p {text-weight: bold;} c) p {bold: true;} d) p {weight: bold;}
Correct Answer: a) p {font-weight: bold;}
Explanation: The font-weight property controls the thickness (boldness) of text.
Question 36
How do you display hyperlinks without an underline in CSS?
a) a {text-decoration: none;} b) a {underline: none;} c) a {text-line: none;} d) a {decoration: none;}
Correct Answer: a) a {text-decoration: none;}
Explanation: The text-decoration property is used to remove or apply text decorations, such as underlining.
Question 37
How do you make each word in a text start with a capital letter using CSS?
a) text-transform: uppercase; b) text-transform: lowercase; c) text-transform: capitalize; d) text-style: capitalize;
Correct Answer: c) text-transform: capitalize;
Explanation: The text-transform: capitalize; CSS property makes the first letter of each word uppercase.
Question 38
Which property is used to change the font of an element in CSS?
a) Font-family b) Font-style c) Font-size d) Text-family
Correct Answer: a) Font-family
Explanation: The font-family property defines which font is applied to the text within an element.
Question 39
How do you make text bold using CSS?
a) Font-weight: bold; b) Font-size: bold; c) Font-style: bold; d) Text-weight: bold;
Correct Answer: a) Font-weight: bold;
Explanation: The font-weight property controls the boldness of the text.
Question 40
How do you display a border on all sides of an element in CSS?
a) Border-width: 1px; b) Border: 1px solid black; c) Border: all 1px; d) Border-style: solid;
Correct Answer: b) Border: 1px solid black;
Explanation: The shorthand border property defines the width, style, and color of a border.