Chapter 210m

HTML Basic in Marathi

मराठीत HTML Basic Examples शिका. Headings, Paragraphs, Links, Images, Buttons आणि Attributes ची Practical Code Examples पाहा.

मागील 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> सर्वात निम्न स्तराची 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: Heading निवडताना Content Hierarchy लक्षात घ्या. फक्त Font Size बदलण्यासाठी Heading वापरू नका.

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: Browser मध्ये 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 पाहा.