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.

background color program CSS,


 


CSS  programe


1] background color program

<!doctype html>

<html>

<body>

<h1 style="background-color:rgb(255, 99, 71);">css apply </h1>

<h1 style="background-color:#ff6347;">css apply</h1>

<h1 style="background-color:hsl(9, 100%, 64%);">css apply </h1>


<h1 style="background-color:rgba(255, 99, 71, 0.5);">css apply </h1>

<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">css apply </h1>

<h1 style="background-color:rgba(600,105,80,0.6);">css apply</h1>

</body>

</html> 


Output    



css apply



2] Table  apply css       

  <html>

<head>

<style>

table, th, td {

  border: 1px solid black;

  border-collapse: collapse;

}

th:nth-child(even),td:nth-child(even) {

  background-color: pink;

}

</style>

</head>

<body>

<h2>Striped Table</h2>

<p>For zebra-striped tables, use the nth-child() 

selector and add a background-color to all even (or odd) table rows:</p>

<table style="width:100%">

  <tr>

    <th>First Name</th>

    <th>Middle Name</th>

    <th>Last Name</th>

    <th>Marks</th>

    <th>Grade</th>

    <th>Percentage</th>

    <th>Remark</th>

  </tr>

  <tr>

   td> aishwarya</td>

    <td> sanjay </td>

    <td> jadha</td>

    <td>80 </td>

    <td> A</td>

    <td> 70%</td>

    <td>No </td>

  </tr>

  <tr>

</Head>

</Body>

</html>


Related Post 

line break html

file upload html

abbr tag in html

Output 

Striped Table

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example