HTML Elements in Marathi
मराठीत HTML Elements शिका. Start Tag, End Tag, Nested Elements, Void Elements आणि Correct HTML Structure सोप्या Examples सह समजून घ्या.
मागील Chapter मध्ये तुम्ही Basic HTML Examples वापरून Web Page तयार करण्यास शिकलात.
आता HTML Elements कसे कार्य करतात ते समजून घेऊया.
HTML Elements हे Web Page चे Building Blocks आहेत. ते Content चे Structure आणि Meaning निश्चित करतात.
या Chapter मध्ये Start Tag, End Tag, Element Content, Nested Elements, Void Elements आणि Correct Nesting शिकाल.
What is an HTML Element?
सामान्यतः HTML Element मध्ये Start Tag, Content आणि End Tag असतात.
Syntax:
<tagname>Content goes here...</tagname>Example:
<h1>Welcome to HTML</h1>| Part | स्पष्टीकरण |
|---|---|
| \<h1> | Start Tag — Element ची सुरुवात दर्शवतो. |
| Welcome to HTML | Element Content — आतील Text. |
| \</h1> | End Tag — Element चा शेवट दर्शवतो. |
HTML Tag आणि HTML Element या पूर्णपणे एकसारख्या संकल्पना नाहीत. Tags हे Element परिभाषित करणाऱ्या Syntax चा भाग आहेत.
Start Tags and End Tags
बहुतेक HTML Elements मध्ये Start Tag आणि End Tag दोन्ही असतात.
End Tag मध्ये Tag Name च्या आधी / असतो.
<p>This is a paragraph.</p>येथे <p> हा Start Tag आणि </p> हा End Tag आहे.
Another Example:
<h2>About Me</h2>
<p>I am learning HTML.</p>सर्व Elements मध्ये End Tag नसतो. काही Elements हे Void Elements असतात.
Nested HTML Elements
एका HTML Element च्या आत दुसरा Element असल्यास त्याला Nested Element म्हणतात.
Example:
<p>
I am learning <strong>HTML</strong> today.
</p>येथे <p> हा Parent Element आणि <strong> हा Child Element आहे.
<strong> त्यातील Content ला विशेष महत्त्व देतो. Browser सामान्यतः तो Bold दाखवतो.
Another Example:
<div>
<h2>My Profile</h2>
<p>Welcome to my website.</p>
</div>येथे <h2> आणि <p> हे <div> मध्ये Nested आहेत.
Nested Structure of an HTML Document
<!DOCTYPE html>
<html>
<head>
<title>HTML Elements</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>Structure Explained:
<html>हा Root Element आहे.<head>आणि<body>हे<html>चे Child Elements आहेत.<title>हा<head>मध्ये आहे.<h1>आणि<p>हे<body>मध्ये आहेत.
Important: <!DOCTYPE html> हे Declaration आहे; HTML Element नाही.
Never Forget the End Tag
काही HTML End Tags विशिष्ट नियमांनुसार वगळता येतात. तरी Beginners नी स्पष्ट Closing Tags लिहिण्याची सवय लावावी.
Recommended:
<p>This is my first paragraph.</p>
<p>This is my second paragraph.</p>काही परिस्थितींमध्ये </p> वगळणे वैध असते; परंतु सर्व End Tags Optional नसतात.
Void Elements
ज्या HTML Elements मध्ये Child Content आणि End Tag नसतो, त्यांना Void Elements म्हणतात.
| Element | कार्य |
|---|---|
| \<br> | Line Break जोडतो. |
| \<hr> | Thematic Break दर्शवतो. |
| \<img> | Image Embed करतो. |
| \<input> | Input Control तयार करतो. |
| \<meta> | Document Metadata देतो. |
| \<link> | External Resource जोडतो. |
Example:
<p>Hello<br>World!</p>Image Example:
<img src="photo.jpg" alt="A landscape photograph"><img> साठी </img> लिहिले जात नाही.
HTML Syntax मध्ये <br /> लिहिता येते; मात्र Trailing Slash आवश्यक नसतो आणि तो Closing Tag तयार करत नाही.
HTML Tag Names and Case
Standard HTML Syntax मध्ये Tag Names Case-insensitive असतात.
<P>This is a paragraph.</P>आणि
<p>This is a paragraph.</p>दोन्ही Paragraph Element म्हणून ओळखले जातात.
Recommended: HTML Tag Names नेहमी Lowercase मध्ये लिहा.
Correct Nesting
Nested Elements योग्य क्रमाने Close केले पाहिजेत.
Incorrect:
<p>This is <strong>important.</p></strong>Correct:
<p>This is <strong>important.</strong></p>आतील Element आधी Close करा आणि त्यानंतर बाहेरील Parent Element Close करा.
Block and Inline Elements: First Look
काही Elements Browser मध्ये सामान्यतः स्वतंत्र Blocks म्हणून दिसतात:
<h2>My Heading</h2>
<p>My paragraph.</p>तर <strong> सारखा Element सामान्यतः त्याच Text Line मध्ये दिसतो:
<p>Learn <strong>HTML</strong> with W3PrimeCode.</p>CSS वापरून Display Behavior बदलता येतो.
Complete Practical Example
<!DOCTYPE html>
<html>
<head>
<title>Understanding HTML Elements</title>
</head>
<body>
<div>
<h1>Welcome to My Website</h1>
<p>
I am learning <strong>HTML</strong>
with W3PrimeCode.
</p>
<hr>
<h2>My Introduction</h2>
<p>
My name is Alex.<br>
I want to become a Web Developer.
</p>
<img
src="https://www.w3.org/Icons/w3c_home"
alt="W3C Logo"
width="100"
>
</div>
</body>
</html>Expected Output: Browser मध्ये Main Heading, महत्त्वाचा Word असलेला Paragraph, Thematic Break, दुसरी Heading, Line Break असलेला Paragraph आणि Image (Resource उपलब्ध असल्यास) दिसेल.
Common Beginner Mistakes
Mistake 1: End Tag विसरणे
Incorrect:
<h1>Welcome to HTMLCorrect:
<h1>Welcome to HTML</h1>Mistake 2: Incorrect Nesting
Incorrect:
<p>Hello <strong>World</p></strong>Correct:
<p>Hello <strong>World</strong></p>Mistake 3: Void Element ला End Tag देणे
Incorrect:
<br></br>Correct:
<br>Try It Yourself
html-elements.html नावाची File तयार करा.
<!DOCTYPE html>
<html>
<head>
<title>HTML Elements Practice</title>
</head>
<body>
<h1>My Profile</h1>
<p>
My name is <strong>Your Name</strong>.
</p>
<hr>
<p>
I am learning HTML.<br>
This is my practice page.
</p>
</body>
</html>तुमचे Tasks:
Your Nameबदला.- एक
<h2>Heading जोडा. - नवीन Paragraph तयार करा.
- Heading आणि Paragraph एका
<div>मध्ये ठेवा. - अर्थपूर्ण
altText सह Image जोडा. - सर्व Nested Elements योग्य क्रमाने Close केले आहेत का ते तपासा.
- File Save करून Browser मध्ये Output पाहा.