Chapter 210m

HTML Basic in Gujarati

ગુજરાતીમાં HTML Basic Examples શીખો. Headings, Paragraphs, Links, Images, Buttons અને Attributes ના Practical Code Examples સાથે HTML શીખો.

પાછલા Chapter માં તમે HTML File બનાવવી, Save કરવી અને Browser માં Open કરવી શીખ્યા.

હવે Practical Examples દ્વારા HTML શીખીએ!

આ Chapter માં Basic HTML Document, Headings, Paragraphs, Links, Images, Buttons અને અન્ય સામાન્ય HTML Elements નો ઉપયોગ શીખશો.

A Basic HTML Document

સામાન્ય HTML Page નું Structure નીચે મુજબ હોય છે.

Example:

html
<!DOCTYPE html>
<html>
<head>
    <title>My First HTML Page</title>
</head>
<body>
    <h1>Welcome to W3PrimeCode</h1>
    <p>This is my first HTML page.</p>
</body>
</html>

Code Explanation

Codeસમજૂતી
\<!DOCTYPE html>Document HTML5 વાપરે છે તેવી જાહેરાત કરે છે.
\<html>HTML Document નું Root Element છે.
\<head>Document Metadata ધરાવે છે.
\<title>Browser Tab નું Title નક્કી કરે છે.
\<body>મુખ્ય Visible Content ધરાવે છે.
\<h1>Top-level Heading બનાવે છે.
\<p>Paragraph બનાવે છે.

HTML Headings

HTML માં <h1> થી <h6> સુધી છ Heading Levels ઉપલબ્ધ છે.

<h1> સૌથી ઉચ્ચ અને <h6> સૌથી નીચા Level ની Heading દર્શાવે છે.

Example:

html
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>

Expected Output: Browser છ Headings ને તેમની Default Styles મુજબ દર્શાવશે.

Important: માત્ર Font Size બદલવા માટે Headings વાપરશો નહીં. Content Hierarchy મુજબ Heading Level પસંદ કરો.

HTML Paragraphs

<p> Element દ્વારા Paragraph બનાવવામાં આવે છે.

Example:

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

Browser સામાન્ય રીતે Paragraphs ને અલગ Blocks તરીકે દર્શાવે છે.

HTML Links

HTML Links દ્વારા એક Page થી બીજા Page અથવા Resource પર જઈ શકાય છે.

Link બનાવવા માટે <a> Element વપરાય છે.

Syntax:

html
<a href="URL">Link Text</a>

Example:

html
<a href="https://www.example.com">
    Visit Example Website
</a>

અહીં href Attribute Link નું Destination નક્કી કરે છે. Visit Example Website એ Clickable Text છે.

HTML Images

Web Page માં Image ઉમેરવા માટે <img> Element વપરાય છે.

Example:

html
<img
    src="https://www.w3.org/Icons/w3c_home"
    alt="W3C Logo"
    width="100"
>

Expected Output: Image Resource ઉપલબ્ધ હોય તો Browser W3C Logo દર્શાવશે.

Attributeકાર્ય
srcImage નું Location નક્કી કરે છે.
altImage માટે Text Alternative આપે છે.
widthImage ની Display Width નક્કી કરે છે.

alt Attribute Accessibility માટે મહત્વપૂર્ણ છે. Image ન દેખાય ત્યારે પણ તેની માહિતી અથવા હેતુ સમજવામાં મદદ કરે છે.

<img> એક Void Element છે. તેને Closing Tag ની જરૂર નથી.

HTML Buttons

Button બનાવવા માટે <button> Element વપરાય છે.

Example:

html
<button type="button">Click Me</button>

Expected Output: Click Me લખાણ ધરાવતું Button દેખાશે.

આ Button પોતાની રીતે કોઈ Custom Action કરતું નથી. આગળ JavaScript દ્વારા Interactivity ઉમેરી શકાય છે.

HTML Line Breaks

<br> Element Text વચ્ચે Line Break ઉમેરે છે.

Example:

html
<p>
    Hello World!<br>
    Welcome to HTML.
</p>

<br> એક Void Element છે. Page Layout માં Spacing બનાવવા માટે વારંવાર <br> વાપરવાને બદલે CSS વાપરો.

HTML Horizontal Rules

<hr> Element Content ના બે Sections વચ્ચે Thematic Break દર્શાવે છે.

Example:

html
<h2>HTML Tutorial</h2>
<p>Learn HTML step by step.</p>

<hr>

<h2>CSS Tutorial</h2>
<p>Learn how to style web pages.</p>

Expected Output: Browser સામાન્ય રીતે બંને Sections વચ્ચે Horizontal Line દર્શાવે છે.

HTML Attributes

HTML Attributes કોઈ Element વિશે વધારાની માહિતી અથવા Configuration આપે છે.

Syntax:

html
<tagname attribute="value">Content</tagname>

Example:

html
<a href="https://www.example.com">Visit Website</a>

અહીં href એક Attribute છે.

બીજું Example:

html
<p title="This is a tooltip">
    Move your mouse over this paragraph.
</p>

ઘણા Desktop Browsers માં Mouse Hover કરવાથી title ની માહિતી Tooltip તરીકે દેખાઈ શકે છે.

How to View HTML Source Code

Desktop Browser માં Page ની ખાલી જગ્યાએ Right-click કરીને View Page Source પસંદ કરો.

સામાન્ય Shortcuts:

  • Windows/Linux: Ctrl + U
  • macOS: Supported Browsers માં Option + Command + U

ચોક્કસ Element તપાસવા માટે Right-click → Inspect વાપરો.

Note: View Page Source સામાન્ય રીતે Original HTML બતાવે છે. Inspect વર્તમાન DOM બતાવે છે, જેમાં JavaScript દ્વારા કરેલા ફેરફારો પણ હોઈ શકે છે.

Complete Practical Example

ચાલો વિવિધ HTML Elements ને એક Web Page માં જોડીએ.

html
<!DOCTYPE html>
<html>
<head>
    <title>My HTML Practice</title>
</head>
<body>

    <h1>Welcome to My Website</h1>

    <p>I am learning HTML with W3PrimeCode.</p>

    <h2>About HTML</h2>

    <p>HTML is used to structure web content.</p>

    <hr>

    <h2>Useful Link</h2>

    <a href="https://www.example.com">
        Visit Example Website
    </a>

    <h2>Sample Image</h2>

    <img
        src="https://www.w3.org/Icons/w3c_home"
        alt="W3C Logo"
        width="100"
    >

    <h2>Button Example</h2>

    <button type="button">Click Me</button>

</body>
</html>

Expected Output: Browser માં Headings, Paragraphs, Horizontal Line, Clickable Link, Image (Resource Load થાય તો) અને Button દેખાશે.

Common Beginner Mistakes

Mistake 1: Closing Tag ભૂલી જવું

Incorrect:

html
<h1>Welcome
<p>Hello World</p>

Correct:

html
<h1>Welcome</h1>
<p>Hello World</p>

Mistake 2: Attribute Values માટે Quotes ન વાપરવા

HTML કેટલીક પરિસ્થિતિઓમાં Quotes વગર Values સ્વીકારે છે. પરંતુ Consistency માટે Quotes વાપરવું Recommended છે.

html
<a href="https://www.example.com">Visit Website</a>

**Mistake 3: Image માં alt ન આપવું**

Informative Image માટે:

html
<img src="photo.jpg" alt="A mountain landscape">

Mistake 4: માત્ર Font Size બદલવા માટે Headings વાપરવી

Headings Content Hierarchy દર્શાવે છે. Appearance બદલવા માટે CSS વાપરો.

Try It Yourself

basic-examples.html નામની File બનાવો.

html
<!DOCTYPE html>
<html>
<head>
    <title>HTML Practice</title>
</head>
<body>

    <h1>My First Website</h1>

    <p>Write your introduction here.</p>

    <h2>My Favorite Website</h2>

    <a href="https://www.example.com">
        Visit Website
    </a>

</body>
</html>

તમારા Tasks:

  1. Main Heading બદલો.
  2. બે નવા Paragraphs ઉમેરો.
  3. નવી <h2> Heading બનાવો.
  4. મનપસંદ Website ની Link ઉમેરો.
  5. <img> દ્વારા Image ઉમેરો.
  6. એક Button બનાવો.
  7. File Save કરીને Browser માં Output જુઓ.