HTML/CSS MCQ

HTML/CSS MCQs – Multiple Choice Questions and Answers – Part 18

Multiple choice questions and answers (MCQs) on HTML/CSS to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are taken from an interview. So you will find questions on basic techniques such as tags, web standards, CSS selector, objects, and more. This quiz will easily prepare anyone to pass their online test.
 
 

1. In CSS, the property that determines the space between the edge of an element and its content is ______

A border

B padding

C margin

D content

B
The ‘padding’ property defines the space between an element’s content (e.g., text) and its edges. It creates internal spacing within the element.
 

2. Which CSS property is used to align text horizontally within a container?

A text-align

B vertical-align

C align-items

D justify-content

A
The text-align property allows horizontal alignment of text inside its container. For example, text-align: center; centers the text in the container. See a full example.
 

3. Which HTML entity is used to display the character “&” (ampersand)?

A &

B <

C >

D ©

A
The entity &amp; is used to display the “&” character in HTML code. Each special character has a corresponding entity, like &lt; for “<" or &gt; for ">“.

 

 
 

4. Which CSS property is used to add a shadow to text?

A box-shadow

B text-shadow

C shadow

D text-effect

B
The text-shadow property is used to add a shadow to text. It takes values such as color, horizontal and vertical offset, and blur radius. See a full example.
 

5. Which HTML tag is used to create a checkbox in a form?

A <input type="checkbox">

B <checkbox>

C <input type="radio">

D <select>

A
The tag <input type="checkbox"> is used to create a checkbox, allowing users to select one or more options in a form. Example:
 

6. Which CSS property allows Flexbox items to automatically adjust to the available width?

A flex-wrap

B flex-shrink

C flex-grow

D flex-basis

C
The flex-grow property allows items in a Flexbox container to grow and take up available space. The default value of 1 lets elements expand proportionally to the free space. See a full example.
 
 

7. What type of link is used to refer to a resource in the same folder as the web page?

A Absolute link

B Relative link

C Resource link

D Internal link

B
A relative link refers to a resource using a path based on the current document’s location. For example, <a href="page2.html"> points to a file named page2.html in the same folder.
 

8. Which CSS property allows you to define the size of columns in a CSS grid?

A grid-template-columns

B grid-template-rows

C grid-column

D grid-gap

A
The grid-template-columns property defines the size of columns in a display: grid container. For example, grid-template-columns: 1fr 2fr; creates two columns where the second is twice as wide as the first. See a full example.
 

9. How do you write a comment in HTML?

A // This is a comment

B <!-- This is a comment -->

C /* This is a comment */

D <!--# This is a comment -->

B
In HTML, a comment is written between the <!-- and --> tags. Comments are not displayed in the browser.
 
 

10. Which HTML tag is used to include an external JavaScript file in a page?

A <script>

B <link>

C <style>

D <js>

A
The <script> tag is used to include JavaScript in a page. If the JavaScript file is external, you can specify the URL with the src attribute. Example: The tag <script src="script.js"></script> refers to an external file named script.js.
mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

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