Conditional Rendering in React Complete Guide with Examples 2026

Image
  Conditional Rendering in React Conditional Rendering is one of the most useful concepts in React. It means showing different content on the screen depending on a condition. For example: If a user is logged in → show Logout If a user is not logged in → show Login If a student has passed → show Congratulations If a product is available → show Buy Now If data is loading → show Loading... React does not have a separate if rendering tag. Instead, we use normal JavaScript conditions such as if, the ternary operator, &&, and switch to decide what should appear in the UI.

Top 15 html MCQ with Answers

Top 15 HTML  MCQ With Answers 





1] What is the purpose of the <a> 

A)  To insert images
B) To define a paragraph
C) To create a hyperlink
D) To create headings

Answer: C) To create a hyperlink

 2] <a> tag specifies URL of the link destination

A) link
B)  src
C)  url
D) href

Answer: D) href

3] Which of the  NOT a valid target value for the <a> tag 

A) _parent
B) _top
C) _newtab
D) _self

Answer: C) _newtab

4] Which tag is commonly used with <a>  tag to define navigation link?

A) <nav>
B) <section>
C) <header>
D) <footer>

Answer: A) <nav>

5] What attribute is used to group radio buttons 

A) value
B) group
C) name
D) id

Answer: C) name

6] How can you hide a radio button but functional?

A) display: none;
B) visibility: hidden;
C) opacity: 0;
D) Both A and C

Answer: D) Both A and C

7]  HTML element for creating a dropdown list?

A) <dropdown>
B)  <option>
C)<select> 
D) <list>

Answer: C) <select>

8] Which tag is usedto define individual items inside a dropdown 

A) <list>
B) <option>
C) <dropdown-item>
D) <item>

Answer: B) <option>

9] Which attribute defines the default value submitted with a dropdown LIST ?

A) value
B) default
C) selected
D) name

Answer: A) value

10] assign a name to a dropdown in a form?

A) Use id="dropdown"
B) Use name="dropdown"
C) Use label="dropdown"
D) Use value="dropdown"

Answer: B) Use name="dropdown"

11] How can you group related options in a dropdown 

A) Using <group>
B) Using <fieldset>
C) Using <optgroup>
D) Using <category>

Answer: C) Using <optgroup>

12] How can you create a dropdown with a custom button instead of a <select> ?

A) Using <button> and JavaScript
B) Using <input type="dropdown">
C) Using <menu> and <option>
D) Using <drop-button>

Answer: A) Using <button> and JavaScript

13] How can you prevent use from selecting a particular option  dropdown?

A) Add disabled to the <option>
B) Add hidden to the <option>
C) Add readonly to the <option>
D) Both A and B

Answer: D) Both A and B

14]  HTML tag to create a file upload input?

A) <upload>
B) <file>
C) <input type="file">
D) <input type="upload">

Answer: C) <input type="file">

15] Which attribute is required for selecting multiple files in  upload field?

A) multiple
B) multiselect
C) select="multiple"
D) multi-file

Answer: A) multiple

Related  Post :-

php if else statements

php program to print alphabet pattern U

javascript Tutorial

Comments