Computer

HTML & CSS Basics MCQs with Answers

What does HTML stand for?
a) Hyper Text Markup Language
b) Hyper Transfer Markup Language
c) Home Tool Markup Language
d) Hyperlink Markup Language

Answer
a) Hyper Text Markup Language

Which of the following is the correct way to add a CSS style in an HTML document?
a) <style> tag
b) <css> tag
c) style attribute in HTML tag
d) Both a and c

Answer
d) Both a and c

Which tag is used to create a hyperlink in HTML?
a) <link>
b) <a>
c) <href>
d) <hyperlink>

Answer
b) <a>

Which property is used to change the background color in CSS?
a) background-color
b) color
c) bg-color
d) background

Answer
a) background-color

Which of the following is the correct syntax to apply a CSS class to an HTML element?
a) <div .class-name>
b) <div class=”class-name”>
c) <div name=”class-name”>
d) <div #class-name>

Answer
b) <div class=”class-name”>

What does the <img> tag do in HTML?
a) Embeds a video
b) Displays an image
c) Embeds audio
d) Creates a hyperlink

Answer
b) Displays an image

Which of the following is used to apply a CSS style to a specific HTML element?
a) Class selector
b) ID selector
c) Universal selector
d) All of the above

Answer
b) ID selector

What is the correct syntax to create a comment in CSS?
a) // Comment
b) /* Comment */
c) <!– Comment –>
d) // This is a comment

Answer
b) /* Comment */

What is the default value of the position property in CSS?
a) static
b) absolute
c) relative
d) fixed

Answer
a) static

Which of the following is the correct syntax to link an external CSS file in HTML?
a) <link rel=”stylesheet” href=”style.css”>
b) <stylesheet src=”style.css”>
c) <css href=”style.css”>
d) <link rel=”css” href=”style.css”>

Answer
a) <link rel=”stylesheet” href=”style.css”>

Which of the following is used to define a table in HTML?
a) <table>
b) <table-define>
c) <tbl>
d) <tble>

Answer
a) <table>

Which of the following is a valid CSS unit of measurement?
a) em
b) cm
c) px
d) All of the above

Answer
d) All of the above

Which HTML tag is used to display a horizontal rule (line) on a webpage?
a) <hr>
b) <line>
c) <break>
d) <rule>

Answer
a) <hr>

What is the correct HTML element to specify a navigation bar?
a) <navbar>
b) <nav>
c) <navigation>
d) <navigation-bar>

Answer
b) <nav>

Which of the following CSS properties is used to control the font size?
a) font-style
b) font-size
c) font-weight
d) text-size

Answer
b) font-size

How do you make a list of items in HTML?
a) <list>
b) <li>
c) <ul>
d) <ol>

Answer
c) <ul>

Which of the following is used to define an unordered list in HTML?
a) <ol>
b) <ul>
c) <li>
d) <list>

Answer
b) <ul>

Which property is used to set the space between words in CSS?
a) word-spacing
b) letter-spacing
c) text-spacing
d) line-spacing

Answer
a) word-spacing

What is the correct HTML element to display a paragraph?
a) <par>
b) <paragraph>
c) <p>
d) <text>

Answer
c) <p>

Which HTML attribute is used to specify an image’s alternative text?
a) alt
b) src
c) title
d) img

Answer
a) alt

How do you select all paragraphs in CSS?
a) p {}
b) .p {}
c) #p {}
d) * {}

Answer
a) p { }

What is the correct way to create an ordered list in HTML?
a) <ol>
b) <ul>
c) <li>
d) <list>

Answer
a) <ol>

Which CSS property is used to change the font family?
a) font-style
b) font-family
c) font-weight
d) text-font

Answer
b) font-family

Which of the following is used to define a comment in HTML?
a) <!– –>
b) //
c) /* */
d) #

Answer
a) <!– –>

What is the default display value of a <div> element in CSS?
a) inline
b) block
c) inline-block
d) none

Answer
b) block

What is the correct HTML tag for embedding a video?
a) <movie>
b) <video>
c) <media>
d) <embed-video>

Answer
b) <video>

How do you make text bold in CSS?
a) font-weight: bold;
b) font-style: bold;
c) text-bold: true;
d) font-size: bold;

Answer
a) font-weight: bold;

Which of the following is used to add a border to an HTML element in CSS?
a) border-style
b) border-width
c) border-color
d) border

Answer
d) border

What is the correct HTML element to specify a header for a document or section?
a) <header>
b) <head>
c) <h1>
d) <section>

Answer
a) <header>

What is the purpose of the z-index property in CSS?
a) To set the position of an element
b) To control the stacking order of elements
c) To apply animation to elements
d) To change the text color of an element

Answer
b) To control the stacking order of elements

What does the border-radius property do in CSS?
a) Defines the size of the border
b) Rounds the corners of an element
c) Changes the width of the border
d) Changes the color of the border

Answer
b) Rounds the corners of an element

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button