css banner

CSS Multiple Choice Questions (MCQs) and Answers

Master CSS with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of CSS. Begin your placement preparation journey now!

Q121

Q121 Which pseudo-class targets the first child element within a parent?

A

:first-of-type

B

:first-child

C

:nth-child(1)

D

:first

Q122

Q122 What does the :nth-child() pseudo-class do?

A

Selects elements based on their sequence number in a group of siblings

B

Changes the style of every nth-child in a list

C

Applies styles to children of a specific parent

D

All of the above

Q123

Q123 How do you select an input element when it has focus?

A

input:focus

B

input:active

C

input:hover

D

input:focus-within

Q124

Q124 What is the difference between pseudo-classes and pseudo-elements?

A

Pseudo-classes target states or conditions, while pseudo-elements target specific parts of an element

B

Pseudo-classes can be combined, but pseudo-elements cannot

C

Pseudo-elements are used for layout, while pseudo-classes are used for styling

D

Pseudo-classes apply to all elements, while pseudo-elements only apply to container elements

Q125

Q125 How do you style the first line of a paragraph?

A

p:first-line { font-weight: bold; }

B

p::first-line { font-weight: bold; }

C

p:first-line:: { font-weight: bold; }

D

p:line:first { font-weight: bold; }

Q126

Q126 How can you style every odd row of a table?

A

tr:nth-child(odd) { background-color: #eee; }

B

tr:odd { background-color: #eee; }

C

table tr:odd-child { background-color: #eee; }

D

tr:nth-odd { background-color: #eee; }

Q127

Q127 How do you create a custom bullet point for list items using CSS?

A

li::before { content: '• '; }

B

ul li:bullet { content: '→ '; }

C

li:marker { content: '→ '; }

D

ul::marker { content: '→ '; }

ad verticalad vertical
ad