Create Your First Functional Component in React JS – Beginner's Guide

Image
Create Your First Functional Component in React JS  1. Introduction When you start learning React JS, one of the first things you will come across is the concept of components. At first, components may seem like just another programming concept, but they are actually the foundation of almost every React application. Think about a website you use every day. It may have a header, navigation menu, login form, product section, and footer. Instead of writing all these elements together in one large file, React allows us to create separate parts and manage them independently. These separate parts are called components. In this tutorial, we are going to create our first functional component in React. We will start with a very simple example and gradually understand how components are created, exported, imported, and displayed on a webpage.  2. What Is a Functional Component in React?   A functional component is simply a JavaScript function that returns a user interface using JSX...

CSS in combinators

 

  combinators in CSS 



1. Descendant selector  

Descendant selector (space) matches all the elements that are descendants of a specified elements, it means that selectors can select element that are descendants of others selector. The element does not have  be  direct child, but rather  descendant down the line.


Syntax:

element1 element2

{

style_properties

}


Descendant selector

 Example 

<!DOCTYPE html>

<html>

<head>

<style>

 ol li { 

color: red;

 } 

 </style>

</head>

 <body>

<ol>

<li>Databases</li> <br>

<ul>

<li>Oracle/PLSQL</li> 

<li>SQL</li>

</ul>

<li>ASP.Net</li>

<li>Java</li>

</ol> </ul>

 </body>

 </html>

Descendant selector 

output 


Descendant selector tag use

Descendant selector 

Example 


<!DOCTYPE html>

<html>

<head>

<style type="text/css">

h1 em{

color: blue; 

}

ul.menu { 

padding:5; list-style:none; 

margin:5px;

 } 

ul.menu li {

 display:inline; 

}

ul.menu li a{ 

margin:8px; 

text-decoration:none;

 }

</style>

</head>

<body>

<h1>This is <em>Heading</em></h1>

<ul class="menu">

 <li><a href="#">Home</a></li>

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

<li><a href="#">Sell</a></li>

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

</ul>

</body>

</html>

Descendant selector

 output 

Descendant selector Tag use

2. Child selector (>) 


This selector is used to match all the elements which are child of a specified element. In another word, The CSS child selector uses the > character to target an element that is a direct child of an element type.

Syntax:


element1 > element2 
{
 style_properties
 }

Child selector

 Example 


<!DOCTYPE html>

<html>

<head> 
<style type="text/css">

ol > li {

color: blue; 
padding:5px;

}

</style>

</head>
<body> 
<ol>

<li>jadhav Publication</li>

<ul>

<li>C Language</li>
<li>IT Tools</li> 
<li>Python</li>
</ul>

<li>www.jadhav.com</li> <li>www.W3C.com</li>

</ol>
</body>
</html>

Child selector 

output 

Child selector Tag use




3. Adjacent sibling selector (+) 

Adjacent sibling selector uses "+" sign to combine two sequences of simple selectors. It is a selector for separating two selectors and matches the second element only when it immediately follows the first element. In this case, both are the children of the same parent element. In another word, It is use to select HTML elements that are adjacent siblings of some other HTML element.

Syntax:


Element+ Element2 
{ 
style_properties
}

Adjacent sibling selector 

Example 


<!DOCTYPE html>
<html>
 <head>

<style type="text/css">
 
h2+ p {
text-align:center;
color: red;
 font-size: 25px;
}

ul.tbp + p {

color: green; 
text-indent. 180px;
}

h1{
Color:pink;
text-align: middle;
}
</style>
</head>
<body>
<h2>Welcome to Tbalaji Publication</h2> <p>We are giving the following items.....</p> <p>Some of our books are given below:</p>

<ul class="top"> 
<li>1-> Python</li>
<li>2-> IT Tools</li>
<>3-> C Language</li>
</ul>
<h1>That's Set</h1>

<p>Goto Our Next Page></p>

</body> 
</html>

Adjacent sibling selector 

output 

Adjacent sibling selector Tag use



General sibling selector (~)
 

  The general sibling combinator (~) separates two selectors and matches the second element only if it follows the first element (though not necessarily immediately) and both are children of the same element.

Syntax:

Former_Element- Target_Element {

style
}


General sibling selector

 Example 


<!DOCTYPE html>
<html>
<head>
<style>
div-p {
background-color: red; 
font-size: 20px;

}
</style>

</head>
<body>

<h2>Welcome to pune Publication</h2>
<div>
<p>Start Code section 1</p>
 <code>Write some code here</code> <p>End of code section 1</p>
</div>
<p>Start Code section 2</p>
 <code>Write some code here</code> 
</body>
</html>


General sibling selector

 output 

General sibling selector tag use


 
Related Post

html frame tag

html form pattern attribute

css box property

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples