HTML Basic
Headings, Paragraphs, Links, Images, Buttons, Attributes, complete HTML Pages എന്നിവയുടെ പ്രായോഗിക ഉദാഹരണങ്ങളിലൂടെ അടിസ്ഥാന HTML പഠിക്കാം.
മുൻ അധ്യായത്തിൽ, Code Editor ഉപയോഗിച്ച് ഒരു HTML File എങ്ങനെ സൃഷ്ടിക്കാം, Save ചെയ്യാം, Open ചെയ്യാം എന്നിവ നിങ്ങൾ പഠിച്ചു.
ഇപ്പോൾ ചില അടിസ്ഥാന HTML Examples പരിചയപ്പെടാം!
Code എഴുതുകയും അതിന്റെ Output നിരീക്ഷിക്കുകയും ചെയ്യുമ്പോൾ HTML മനസ്സിലാക്കുന്നത് കൂടുതൽ എളുപ്പമാകും.
ഈ അധ്യായത്തിൽ, ഒരു അടിസ്ഥാന HTML Document എങ്ങനെ സൃഷ്ടിക്കാമെന്നും Headings, Paragraphs, Links, Images, Buttons തുടങ്ങിയ സാധാരണ Elements എങ്ങനെ ചേർക്കാമെന്നും നിങ്ങൾ പഠിക്കും.
HTML Source Code എങ്ങനെ കാണാമെന്നും HTML Tags-ഉം Attributes-ഉം തമ്മിലുള്ള വ്യത്യാസം എന്താണെന്നും നിങ്ങൾ പഠിക്കും.
A Basic HTML Document
ഓരോ HTML Page-ഉം ഒരു അടിസ്ഥാന Document Structure ഉപയോഗിച്ചാണ് ആരംഭിക്കുന്നത്.
Example:
<!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>Example Explained
| Code | Description |
|---|---|
| \<!DOCTYPE html> | Document HTML5 ഉപയോഗിക്കുന്നുവെന്ന് പ്രഖ്യാപിക്കുന്നു. |
| \<html> | HTML Document-ന്റെ Root Element നിർവചിക്കുന്നു. |
| \<head> | Document Metadata ഉൾക്കൊള്ളുന്നു. |
| \<title> | Browser Tab-ന്റെ Title നിർവചിക്കുന്നു. |
| \<body> | പ്രധാനമായും കാണാവുന്ന Page Content ഉൾക്കൊള്ളുന്നു. |
| \<h1> | ഏറ്റവും ഉയർന്ന തലത്തിലുള്ള Heading നിർവചിക്കുന്നു. |
| \<p> | ഒരു Paragraph നിർവചിക്കുന്നു. |
Important: <body>-യുടെ ഉള്ളിലുള്ള Content ആണ് സാധാരണയായി users Web Page-ൽ കാണുന്നത്.
HTML Headings
ഒരു Web Page-ൽ Titles-ഉം Section Headings-ഉം നിർവചിക്കാൻ HTML Headings ഉപയോഗിക്കുന്നു.
HTML-ൽ <h1> മുതൽ <h6> വരെ ആറ് തലത്തിലുള്ള Headings ലഭ്യമാണ്.
<h1>ഏറ്റവും ഉയർന്ന തലത്തിലുള്ള Heading ആണ്.<h6>ഏറ്റവും താഴ്ന്ന തലത്തിലുള്ള Heading ആണ്.
Example:
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>യഥാർത്ഥ Heading Sizes Browser-ന്റെ Default Styles അല്ലെങ്കിൽ Page-ൽ പ്രയോഗിച്ചിരിക്കുന്ന CSS അനുസരിച്ചിരിക്കും.
Remember: Text വലുതാക്കാനോ ചെറുതാക്കാനോ വേണ്ടി മാത്രം Heading Levels തിരഞ്ഞെടുക്കരുത്. നിങ്ങളുടെ Content-ന്റെ Structure-ഉം Hierarchy-ഉം അനുസരിച്ചാണ് അവ തിരഞ്ഞെടുക്കേണ്ടത്.
HTML Paragraphs
<p> Element ഒരു Paragraph നിർവചിക്കുന്നു.
Descriptions, Explanations, Introductions തുടങ്ങിയ Text Blocks പ്രദർശിപ്പിക്കാൻ സാധാരണയായി Paragraph ഉപയോഗിക്കുന്നു.
Example:
<p>This is my first paragraph.</p>
<p>This is my second paragraph.</p>Browsers സാധാരണയായി Paragraphs-നെ Default Spacing ഉള്ള പ്രത്യേക Blocks ആയി പ്രദർശിപ്പിക്കുന്നു.
ആവശ്യാനുസരണം നിങ്ങൾക്ക് എത്ര Paragraphs വേണമെങ്കിലും സൃഷ്ടിക്കാം.
HTML Links
ഒരു Web Page-ൽ നിന്ന് മറ്റൊരു Web Page-ലേക്ക് പോകാൻ users-നെ സഹായിക്കുന്നത് HTML Links ആണ്.
<a> Element ഉപയോഗിച്ചാണ് Links സൃഷ്ടിക്കുന്നത്.
Basic Syntax:
<a href="URL">Link Text</a>Example:
<a href="https://www.example.com">
Visit Example Website
</a>Example Explained
<a>ഒരു Hyperlink നിർവചിക്കുന്നു.hrefLink-ന്റെ Destination വ്യക്തമാക്കുന്ന ഒരു Attribute ആണ്.Visit Example Websiteക്ലിക്ക് ചെയ്യാവുന്ന Link Text ആണ്.</a>Element അവസാനിപ്പിക്കുന്നു.
Important: Link എവിടേക്കാണ് കൊണ്ടുപോകുന്നതെന്ന് users-ന് മനസ്സിലാകുന്ന തരത്തിലുള്ള അർത്ഥവത്തായ Link Text എപ്പോഴും ഉപയോഗിക്കുക.
HTML Images
ഒരു HTML Page-ൽ Image ഉൾപ്പെടുത്താൻ <img> Element ഉപയോഗിക്കുന്നു.
മറ്റ് പല HTML Elements-ൽ നിന്നും വ്യത്യസ്തമായി, <img> ഒരു Void Element ആണ്. അതിന് End Tag ആവശ്യമില്ല.
Basic Syntax:
<img src="image.jpg" alt="Image description">Example:
<img
src="https://www.w3.org/Icons/w3c_home"
alt="W3C Logo"
width="100"
>Expected Output:
നൽകിയിരിക്കുന്ന Image Resource ലഭ്യമാണെങ്കിൽ Browser ആ Image പ്രദർശിപ്പിക്കും.
Example Explained
| Attribute | Description |
|---|---|
| src | Image-ന്റെ Location വ്യക്തമാക്കുന്നു. |
| alt | Image-നെ വിവരിക്കുന്ന Alternative Text നൽകുന്നു. |
| width | Image-ന്റെ പ്രദർശിപ്പിക്കുന്ന Width വ്യക്തമാക്കുന്നു. |
Why is alt important?
ഒരു Image പ്രദർശിപ്പിക്കാൻ കഴിയാത്തപ്പോൾ alt Attribute അതിന് പകരമായി Text നൽകുന്നു. Assistive Technologies ഉപയോഗിക്കുന്ന users-ന് Image-ന്റെ ഉദ്ദേശ്യം മനസ്സിലാക്കാനും ഇത് സഹായിക്കുന്നു.
വിവരപ്രദമായ Images-ന് അർത്ഥവത്തായ Alternative Text എഴുതുക.
HTML Buttons
ഒരു Web Page-ൽ Button സൃഷ്ടിക്കാൻ <button> Element ഉപയോഗിക്കുന്നു.
Example:
<button type="button">Click Me</button>Important: ഈ Button സ്വയം ഒരു Custom Action നിർവഹിക്കില്ല. User Button ക്ലിക്ക് ചെയ്യുമ്പോൾ എന്ത് സംഭവിക്കണമെന്ന് നിർവചിക്കാൻ JavaScript ഉപയോഗിക്കാം.
Interactive Buttons-നെക്കുറിച്ച് കൂടുതൽ വിവരങ്ങൾ നിങ്ങൾക്ക് പിന്നീടുള്ള Tutorials-ൽ പഠിക്കാം.
HTML Line Breaks
Text-നുള്ളിൽ ഒരു Line Break ചേർക്കാൻ <br> Element ഉപയോഗിക്കുന്നു.
ഇത് ഒരു Void Element ആണ്. അതിനാൽ Closing Tag ആവശ്യമില്ല.
Example:
<p>
Hello World!<br>
Welcome to HTML.
</p>ഒരു Address അല്ലെങ്കിൽ Poem പോലുള്ള Content-ൽ Line Break ആവശ്യമായിടത്ത് <br> ഉപയോഗിക്കുക.
Page Sections-ക്കിടയിൽ Spacing സൃഷ്ടിക്കാൻ തുടർച്ചയായി ഒന്നിലധികം <br> Elements ഉപയോഗിക്കരുത്. Layout-നും Spacing-നും CSS ആണ് കൂടുതൽ അനുയോജ്യം.
HTML Horizontal Rules
Content-ന്റെ Sections-ക്കിടയിലുള്ള Thematic Break സൂചിപ്പിക്കാൻ <hr> Element ഉപയോഗിക്കുന്നു.
Browsers സാധാരണയായി ഇതിനെ ഒരു Horizontal Line ആയി പ്രദർശിപ്പിക്കുന്നു.
Example:
<h2>HTML Tutorial</h2>
<p>Learn HTML step by step.</p>
<hr>
<h2>CSS Tutorial</h2>
<p>Learn how to style web pages.</p>HTML Attributes
HTML Elements-ന് അധിക വിവരങ്ങളോ Configuration-ഓ നൽകുന്നത് HTML Attributes ആണ്.
സാധാരണയായി ഇവ Start Tag-ന്റെ ഉള്ളിലാണ് എഴുതുന്നത്.
Example:
<a href="https://www.example.com">Visit Website</a>ഇവിടെ href ഒരു Attribute ആണ്.
Another Example:
<p title="This is a tooltip">
Move your mouse over this paragraph.
</p>title Attribute അധിക Advisory Information നൽകാൻ ഉപയോഗിക്കാം. User ഒരു Element-ന്റെ മുകളിൽ Mouse Hover ചെയ്യുമ്പോൾ പല Desktop Browsers-ലും ഇത് Tooltip ആയി പ്രദർശിപ്പിക്കും.
General Syntax:
<tagname attribute="value">Content</tagname>മിക്ക Attributes-ഉം ഒരു Name-ഉം Value-ഉം ഉപയോഗിച്ചാണ് എഴുതുന്നത്.
പിന്നീടുള്ള ഒരു അധ്യായത്തിൽ HTML Attributes കൂടുതൽ വിശദമായി പഠിക്കാം.
How to View HTML Source Code
നിങ്ങളുടെ Browser ഉപയോഗിച്ച് നിരവധി Web Pages-ന്റെ HTML Source Code പരിശോധിക്കാം.
Method 1: View Page Source
മിക്ക Desktop Browsers-ലും:
- ഒരു Web Page Open ചെയ്യുക.
- ഒഴിഞ്ഞ സ്ഥലത്ത് Right-click ചെയ്യുക.
- View Page Source തിരഞ്ഞെടുക്കുക.
സാധാരണയായി താഴെ പറയുന്ന Keyboard Shortcuts-ഉം ഉപയോഗിക്കാം:
- Windows/Linux:
Ctrl + U - macOS: പിന്തുണയ്ക്കുന്ന Browsers-ൽ
Option + Command + U
ഇത് ആ Page-ന് ലഭിച്ച HTML Source പ്രദർശിപ്പിക്കുന്നു.
Method 2: Inspect Element
ആധുനിക Desktop Browsers-ൽ Developer Tools ഉൾപ്പെടുത്തിയിട്ടുണ്ട്.
ഒരു പ്രത്യേക Element Inspect ചെയ്യാൻ:
- ആ Element-ൽ Right-click ചെയ്യുക.
- Inspect തിരഞ്ഞെടുക്കുക.
- Elements Panel-ൽ HTML പരിശോധിക്കുക.
Note: View Page Source-ഉം Inspect-ഉം ഒരേ കാര്യമല്ല. View Page Source സാധാരണയായി Original HTML Response ആണ് കാണിക്കുന്നത്. എന്നാൽ Inspect, JavaScript മാറ്റങ്ങൾ വരുത്തിയിട്ടുണ്ടെങ്കിൽ അവ ഉൾപ്പെടെയുള്ള നിലവിലെ DOM ആണ് പ്രദർശിപ്പിക്കുന്നത്.
Complete Practical Example
നിരവധി HTML Elements ഒരൊറ്റ Web Page-ൽ ചേർത്ത് നോക്കാം.
Example:
<!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 താഴെ പറയുന്നവ പ്രദർശിപ്പിക്കും:
- ഒരു Main Heading.
- രണ്ട് Informational Paragraphs.
- Section Headings.
- ഒരു Thematic Break.
- ക്ലിക്ക് ചെയ്യാവുന്ന ഒരു Link.
- Resource വിജയകരമായി Load ചെയ്താൽ ഒരു Image.
- ഒരു Button.
ഒന്നിലധികം HTML Elements ഒരുമിച്ച് ഉപയോഗിച്ച് ഒരു ലളിതമായ Web Page എങ്ങനെ സൃഷ്ടിക്കാമെന്ന് ഈ Example കാണിക്കുന്നു.
Common Beginner Mistakes
Mistake 1: Forgetting the Closing Tag
Incorrect:
<h1>Welcome
<p>Hello World</p>Correct:
<h1>Welcome</h1>
<p>Hello World</p>Mistake 2: Forgetting Quotes Around Attribute Values
HTML-ൽ ചില Attribute Values Quotes ഇല്ലാതെയും എഴുതാം. എങ്കിലും എല്ലായിടത്തും Quotes ഉപയോഗിക്കുന്നതാണ് ശുപാർശ ചെയ്യുന്നത്.
Recommended:
<a href="https://www.example.com">Visit Website</a>Mistake 3: Missing Image Alternative Text
Not Recommended:
<img src="photo.jpg">Recommended for an informative Image:
<img src="photo.jpg" alt="A mountain landscape">Mistake 4: Using Heading Elements Only to Change Font Size
Headings Content Hierarchy വ്യക്തമാക്കാനാണ് ഉപയോഗിക്കുന്നത്. Font Size-ഉം Appearance-ഉം നിയന്ത്രിക്കാൻ CSS ഉപയോഗിക്കുക.
Try It Yourself
basic-examples.html എന്ന പേരിൽ ഒരു File സൃഷ്ടിക്കുക.
താഴെ കൊടുത്തിരിക്കുന്ന Starter Code ഉപയോഗിക്കുക:
<!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>Your Tasks:
- Main Heading മാറ്റുക.
- രണ്ട് പുതിയ Paragraphs ചേർക്കുക.
<h2>ഉപയോഗിച്ച് മറ്റൊരു Heading ചേർക്കുക.- നിങ്ങൾക്ക് ഇഷ്ടമുള്ള ഒരു Website-ലേക്കുള്ള Link സൃഷ്ടിക്കുക.
<img>ഉപയോഗിച്ച് ഒരു Image ചേർക്കുക.- ഒരു Button ചേർക്കുക.
- File Save ചെയ്ത് Browser-ൽ Output കാണുക.