Chapter 310m

HTML Elements in Gujarati

ગુજરાતીમાં 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:

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 ને Define કરતા 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 Element માં End Tag હોતો નથી. કેટલાક 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 દર્શાવે છે.

Another 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 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:

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 ઉપલબ્ધ હોય તો) દેખાશે.

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 જુઓ.