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 Margin Explained -Top, Right, Bottom, Left

What Is CSS Margin? Syntax, Properties, and Examples

What is CSS Margin

This Blog You Will Learn

ஃ What is Margin in CSS
ஃ Why Margin use
ஃ Syntax 
ஃ CSS Margin Explained
ஃ Advantage of CSS Margin
ஃ structure diagram examples
ஃ Explain Program
ஃ Output
ஃ CSS Margin  Properties

What is Margin in CSS

CSS Margin is the space outside an HTML element border.
Margin creates distance between one element and other surrounding elements.
Margin controls outer spacing

Why Margin use

  1.  Improves readability
  2. prevents elements from touching each  other
  3. Helps create clean  layouts

Syntax 

selector
{
margin-top: value;
margin-right: value;
margin-bottom: value;
margin-left: value;

}

CSS Margin Explained

1) one Value

margin: 20px;

  • All Sides =20px

2) Two Values

margin:20px 30px;

  • Top And Bottom =20px
  • Left And Right =  30px

3) Three Values 

margin: 20px 30px 40px;

  • Top  =10px
  • Left& Right =20px
  • Bottom =30px
4) Four Values

margin: 10px 20px 30px 40px;

  • top→Right→Bottom→Left

Advantage of CSS Margin

✅Creates Space Between  Elements

✅ Improves page Readability

✅ Helps in Layout Design

✅ Easy Element Positioning

✅ Supports Responsive Design

✅ Allow Individial Side Control

✅ Centers Elements Easily

✅ Cleaner and Professional UI

CSS position property

ஃ structure diagram examples

CSS Margin Explained -Top, Right, Bottom, Left


CSS Margin  Properties


margin-top: 50px; /* space*/
  margin-bottom: 100px; /* controls space below element */
  margin-right: 80px; /* right side space */
  margin-left: 90px; /* space left side */

What Is CSS Margin? Syntax, Properties
Example
s

<!DOCTYPE html>
<html>
<head>
<style>
div {
  border: 2px solid blue;
  margin-top: 50px;
  margin-bottom: 100px;
  margin-right: 80px;
  margin-left: 90px;
  background-color: lightgrey;
  color:brown;
}
</style>
</head>
<body>

<h2> CSS Margin Properties </h2>

<div>The margin property controls the outer spacing around
HTML elements.<br>CSS margin is all about space on the
outside of an element. Think of it as the breathing
room between one element and the others aroundit.</div>

</body>
</html>


What is CSS Margin? Syntax, Properties
Explain Program

Step  1] 

<!DOCTYPE html>

  • This declare the document type.
  • browser that the document is written in html

Step 2 ]

<html>.... . </html>

  • html is the root element of the html page.
  •  Every thing inside it is part of the webpage.

Step 3]

<head>....</head>

  • Contains internal CSS and page- related settings.
  • <head> shown directly on webpage.
  • Control CSS Styles & page settings

Step 4]

CSS Styling

<style>
div {
  border: 2px solid blue;
  margin-top: 50px;
  margin-bottom: 100px;
  margin-right: 390px;
  margin-left: 80px;
  background-color: lightgrey;
  color:brown;
}
</style>

  • <div> Elements in the document.
  • Create 2px blue border.
  • Add 50px space above the div.
  • Adds 100px  space below the div.
  • Add 390px space on the right reducing available width.
  • Add 80px space on the left.
  •  Applies a light grey background to the div content area.
  • Sets text color inside div to brown.

Step 5]

<body> Section

<body>

<h2> CSS Margin Properties </h2>


<div>The margin property controls the outer spacing around
HTML elements.<br>CSS margin is all about space on the
outside of an element. Think of it as the breathing
room between one element and the others aroundit.</div>

</body>
</html>

  • Contains the visible content of the webpage.
  • Display text inside a styled div
  • <br> line break
  • <div> tag CSS styles defined 
Step 6]

   Closing tag

</body>
</html>

Whavt is CSS Margin? Syntax, Properties
Output

What Is CSS Margin Syntax


Related Post :-

What is linear Gradient in CSS
What is CSS Gradient
CSS Attribute Selector Explained

Comments

Popular posts from this blog

HTML Tag

CSS Text Color Explained with Syntax and HTML Examples

CSS Outline Offset Property with Practical Examples