HTML/CSS MCQ

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

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. What element defines the main structure of an HTML page?

A <html>

B <head>

C <body>

D <header>

A
The <html> element is the root element that contains all the content of a web page. Inside this element, we find the <head> (for metadata) and <body> (for visible page content).
 

2. Which HTML tag is used to include a description in the source code of the page that is used by search engines?

A <meta>

B <title>

C <description>

D <keywords>

A
The <meta> element is used to include metadata such as description, keywords, charset, etc. This information is often used by search engines to better understand the page’s content.
 

3. Which CSS pseudo-class targets a link when it is hovered by the mouse?

A :active

B :focus

C :hover

D :visited

C
The :hover pseudo-class is used to apply styles to an element when it’s hovered by the mouse. This is commonly used for links. See a complete example.
 
 

4. Which HTML tag is used to define a footer in a document?

A <footer>

B <div>

C <section>

D <footer-section>

A
The <footer> tag is used to define a footer in an HTML document. This tag typically contains copyright information, navigation links, or contact info.
 

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

A <input type="button">

B <button>

C <input type="submit">

D All of the above

D
All the tags mentioned can be used to create a button in a form. <input type="button"> and <input type="submit"> create clickable buttons, while the <button> tag also creates a button with customizable content.
 

6. Which HTML tag is used to define the character encoding of a page?

A <meta charset="UTF-8">

B <meta>

C <title>

D <link>

A
The <meta charset="UTF-8"> tag defines the character encoding for the HTML page. UTF-8 is a standard encoding that supports most characters.
 
 

7. Which CSS property allows you to position an element relative to its container?

A position: absolute;

B position: fixed;

C position: relative;

D position: sticky;

C
The position: relative; property positions an element relative to its normal position in the page flow. It moves from its original spot without affecting other elements. See a complete example.
 

8. Which CSS property is used to change the thickness of text?

A font-weight

B font-style

C text-align

D font-family

A
The font-weight property is used to set the thickness of text. For example, font-weight: bold; makes the text bold.
 

9. Which CSS property is used to add space outside of an element?

A padding

B margin

C spacing

D border-spacing

B
The margin property sets the space around elements (outside the element). In contrast, padding adds space inside the element, between the content and its border.
 
 

10. Which CSS property defines the alignment of items along the cross axis in a Flexbox container?

A justify-content

B align-items

C flex-wrap

D align-self

B
The align-items property aligns items along the cross axis (vertical by default) in a Flexbox container. It can be used to center, stretch, or align items to the top, center, or bottom. See a complete example.
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 *