Chapter 310m

HTML Elements in Bengali

বাংলায় 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। এগুলো Page-এর বিভিন্ন 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:

html
<tagname>Content goes here...</tagname>

Example:

html
<h1>Welcome to HTML</h1>
Partব্যাখ্যা
\<h1>Start Tag — Element-এর শুরু নির্দেশ করে।
Welcome to HTMLElement 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-এর আগে / থাকে।

html
<p>This is a paragraph.</p>

এখানে <p> হলো Start Tag এবং </p> হলো End Tag।

Another Example:

html
<h2>About Me</h2>
<p>I am learning HTML.</p>

সব HTML Elements-এর End Tag থাকে না। কিছু Elements হলো Void Elements।

Nested HTML Elements

একটি HTML Element-এর ভিতরে আরেকটি Element থাকলে সেটিকে Nested Element বলে।

Example:

html
<p>
    I am learning <strong>HTML</strong> today.
</p>

এখানে <p> হলো Parent Element এবং <strong> হলো Child Element।

<strong> তার Content-কে বিশেষ গুরুত্ব দেয়। Browser সাধারণত সেটি Bold দেখায়।

আরেকটি Example:

html
<div>
    <h2>My Profile</h2>
    <p>Welcome to my website.</p>
</div>

এখানে <h2> ও <p> উভয়ই <div>-এর ভিতরে Nested।

Nested Structure of an HTML Document

html
<!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:

html
<p>This is my first paragraph.</p>
<p>This is my second paragraph.</p>

কিছু পরিস্থিতিতে </p> বাদ দেওয়া বৈধ হলেও সব End Tag 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:

html
<p>Hello<br>World!</p>

Image Example:

html
<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।

html
<P>This is a paragraph.</P>

এবং

html
<p>This is a paragraph.</p>

উভয়ই Paragraph Element হিসেবে স্বীকৃত।

Recommended: সব HTML Tag Names Lowercase-এ লিখুন।

Correct Nesting

Nested Elements সঠিক ক্রমে Close করতে হয়।

Incorrect:

html
<p>This is <strong>important.</p></strong>

Correct:

html
<p>This is <strong>important.</strong></p>

ভিতরের Element আগে Close করুন, তারপর বাইরের Parent Element।

Block and Inline Elements: First Look

কিছু Elements Browser-এ সাধারণত আলাদা Blocks হিসেবে দেখা যায়:

html
<h2>My Heading</h2>
<p>My paragraph.</p>

অন্যদিকে <strong> সাধারণত একই Text Line-এর মধ্যে থাকে:

html
<p>Learn <strong>HTML</strong> with W3PrimeCode.</p>

CSS দিয়ে Display Behavior পরিবর্তন করা যায়।

Complete Practical Example

html
<!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 পাওয়া গেলে) দেখা যাবে।

এখানে Nested Elements ও Void Elements একসঙ্গে ব্যবহার করা হয়েছে।

Common Beginner Mistakes

Mistake 1: End Tag ভুলে যাওয়া

Incorrect:

html
<h1>Welcome to HTML

Correct:

html
<h1>Welcome to HTML</h1>

Mistake 2: Incorrect Nesting

Incorrect:

html
<p>Hello <strong>World</p></strong>

Correct:

html
<p>Hello <strong>World</strong></p>

Mistake 3: Void Element-এর End Tag লেখা

Incorrect:

html
<br></br>

Correct:

html
<br>

Try It Yourself

html-elements.html নামে একটি File তৈরি করুন।

html
<!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:

  1. Your Name পরিবর্তন করুন।
  2. একটি <h2> Heading যোগ করুন।
  3. নতুন Paragraph তৈরি করুন।
  4. একটি Heading ও Paragraph-কে <div>-এর ভিতরে রাখুন।
  5. অর্থপূর্ণ alt Text-সহ Image যোগ করুন।
  6. সব Nested Elements সঠিকভাবে Close হয়েছে কি না দেখুন।
  7. File Save করে Browser-এ Output দেখুন।