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.

Horizontal navigation bar Web designing


 
Horizontal navigation bar

   The horizontal navigation bar is a most common type of  the navigation menu bar. It list the major page side-by-side and is placed in the website header.


Horizontal navigation bar Example 

<!DOCTYPE html>

<html>

<head><style>

ul{

list-style-type: none;

 margin: 0; padding: 0; 

overflow: hidden; 

background-color: #f09d28;}

li {

float: left; 

border-right:1px solid #bbb; } 

li:last-child { border-right: none;}

li a{ display: block; 

color: white; 

text-align: center;

padding: 14px 16px; text-decoration: none;

background-color:#f09d28;

 color: yellow;}

li a:hover:not(.active) { background-color: #111;}

.active {background-color: #2BE40; color:red;}

 </style>

<h1> College of computer </h1>

<li><a class="active" href="#home">Home</a></li>

 <li><a href="#About">About us</a></li>

 <li><a href="#courses">Courses</a></li>

<li style="float: right"><a href="download">download</a></li>

</ul></body>

</head></html>


Horizontal navigation bar Output


Horizontal navigation bar

Create CSS Navigation Bar 

Program


<!DOCTYPE HTML>

<html>

<head>

<title>Example shows </title>

<style>

body {

margin: 0px; }

ul{

list-style-type: none;

margin: 0px; padding: 0px;

width: 25%;

background-color:#f1f1f1;

position: fixed; height: 100%;

overflow: auto;

}

li a {

display: block;

color: #000;

padding: 8px 16px; text-decoration: none;

}

li a.active {

background-color: #f09d28; 

color:white; }

li a:hover:not(.active) {

background-color:#555; color:white;

}

</style>

</head>

<body>

<h2 style="text-align:center;"> Welcome ClassRoom </h2>

<ul>

<li><a class="active" href="#home">Home</a></li>

<li><a href="#about">About</a></li>

<li><a href="#meditation">Meditation</a></li>

<li><a href="#gallery">Gallery</a></li>

<li><a href="#contact">Contact</a></li>

</ul>

<div style="margin-left:25%; padding:1px 16px; height:1000px;">

 <h2>This is my Own Earth</h2>

<h4>The happiness of your life depends upon the quality of your thoughts: therefore, guard accordingly, and take care that you entertain no notions unsuitable to virtue and reasonable nature.<br></h4>

<p>I am not a Handsome guy, but I can give my hand-to-some one who needs help. <br></p>

</div>

</body>

</html>


Create CSS  Navigation Bar 

output 


Create Navigation Bar


Related post :-

inline css in html

html iframe

html id attribute

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

HTML Input Type Submit Syntax and Example