HTML Attributes Tutorial in Hindi | href, src, alt, style Attribute with Examples
HTML Text Formatting Elements
HTML เคेเค्เคธ्เค เคซॉเคฐ्เคฎेเคिंเค เคเคฒिเคฎेंเค्เคธ
HTML also defines special elements for defining text with a special meaning.HTML เคฎें เคुเค special elements เคนोเคคे เคนैं เคो text เคो เค เคฒเค meaning เคเคฐ style เคฆेเคจे เคे เคฒिเค use เคिเค เคाเคคे เคนैं।
HTML uses elements like <b> and <i> for formatting output like bold or italic text.HTML เคฎें <b> เคเคฐ <i> เคैเคธे elements text เคो bold เคฏा italic เคฆिเคाเคจे เคे เคฒिเค use เคिเค เคाเคคे เคนैं।
- <b> - Bold text (เคฎोเคा เคेเค्เคธ्เค)
- <strong> - Important text (เคฎเคนเคค्เคตเคชूเคฐ्เคฃ เคेเค्เคธ्เค)
- <i> - Italic text (เคคिเคฐเคा เคेเค्เคธ्เค)
- <em> - Emphasized text (เคोเคฐ เคฆेเคเคฐ เคฒिเคा เคเคฏा เคेเค्เคธ्เค)
- <u> - Underline text (เคฐेเคा เคตाเคฒा เคेเค्เคธ्เค)
- <mark> - Marked text (เคนाเคเคฒाเคเค เคिเคฏा เคนुเค เคेเค्เคธ्เค)
- <small> - Small text (เคोเคा เคेเค्เคธ्เค)
- <big> - Big text (เคฌเคก़ा เคेเค्เคธ्เค)
- <del> - Deleted text (เคนเคाเคฏा เคเคฏा เคेเค्เคธ्เค)
- <ins> - Inserted text (เคोเคก़ा เคเคฏा เคेเค्เคธ्เค)
- <sub> - Subscript text (เคจीเคे เคฒिเคा เคेเค्เคธ्เค)
- <sup> - Superscript text (เคเคชเคฐ เคฒिเคा เคेเค्เคธ्เค)
HTML Attributes (HTML เคเค्เคฐिเคฌ्เคฏूเค्เคธ)
HTML attributes provide additional information about HTML elements. Attributes are used to define extra properties of elements and they are written inside the start tag of an element.
HTML attributes HTML elements เคे เคฌाเคฐे เคฎें เค เคคिเคฐिเค्เคค เคाเคจเคाเคฐी เคช्เคฐเคฆाเคจ เคเคฐเคคे เคนैं। เคฏे elements เคी extra properties เคो define เคเคฐเคจे เคे เคฒिเค เคเคชเคฏोเค เคिเค เคाเคคे เคนैं เคเคฐ เคนเคฎेเคถा element เคे start tag เคे เค ंเคฆเคฐ เคฒिเคे เคाเคคे เคนैं।
- All HTML elements can have attributes
- Attributes provide additional information about an element
- Attributes are always specified in the start tag
- Attributes usually come in name/value pairs like: name="value"
- All HTML elements can have attributes – เคธเคญी HTML elements เคฎें attributes เคนो เคธเคเคคे เคนैं
- Attributes provide additional information about an element – Attributes เคिเคธी element เคे เคฌाเคฐे เคฎें เค เคคिเคฐिเค्เคค เคाเคจเคाเคฐी เคฆेเคคे เคนैं
- Attributes are always specified in the start tag – Attributes เคนเคฎेเคถा start tag เคฎें เคฒिเคे เคाเคคे เคนैं
- Attributes usually come in name/value pairs like: name="value" – Attributes เคเคฎเคคौเคฐ เคชเคฐ name/value pair เคฎें เคนोเคคे เคนैं
The href Attribute
HTML links are defined with the <a> tag. The link address is specified in the href attribute:
Example
<a href="https://youtube.com/@musicmp3song001?si=SAcoGbSD5xXofsWD">This is a link</a>
HTML links <a> tag เคธे define เคिเค เคाเคคे เคนैं। Link เคा address href attribute เคฎें เคฒिเคा เคाเคคा เคนै।
The src Attribute
HTML images are defined with the <img> tag.The filename of the image source is specified in the src attribute:
HTML images <img> tag เคธे define เคนोเคคी เคนैं। Image เคा filename src attribute เคฎें เคฒिเคा เคाเคคा เคนै।
Example
<img src="img_girl.jpg">
The above example shows how an image is added in HTML using the src attribute.
เคเคชเคฐ เคฆिเคฏा เคเคฏा เคเคฆाเคนเคฐเคฃ เคฆिเคाเคคा เคนै เคि HTML เคฎें image เคो src attribute เคी เคฎเคฆเคฆ เคธे เคैเคธे เคोเคก़ा เคाเคคा เคนै।
The width and height Attributes
HTML images also have width and height attributes, which specify the width and height of the image.
HTML images เคฎें width เคเคฐ height attributes เคญी เคนोเคคे เคนैं, เคो image เคी เคौเคก़ाเค เคเคฐ เคँเคाเค เคो เคจिเคฐ्เคงाเคฐिเคค เคเคฐเคคे เคนैं।
Example
<img src="img_girl.jpg" width="500" height="600">
The width and height are specified in pixels by default; so width="500" means 500 pixels wide.
width เคเคฐ height default เคฐूเคช เคธे pixels เคฎें เคนोเคคे เคนैं; เคเคธเคฒिเค width="500" เคा เคฎเคคเคฒเคฌ 500 pixels เคौเคก़ाเค เคนै।
You will learn more about images in our HTML Images chapter.
เคเคช HTML Images chapter เคฎें images เคे เคฌाเคฐे เคฎें เคเคฐ เค เคงिเค เคธीเคेंเคे।
The alt Attribute
The alt attribute specifies an alternative text to be used, if an image cannot be displayed.
alt attribute เคเค เคตैเคเคฒ्เคชिเค (alternative) text เคฌเคคाเคคा เคนै, เคो เคคเคฌ เคฆिเคाเค เคฆेเคคा เคนै เคเคฌ image display เคจเคนीं เคนो เคชाเคคी।
The value of the alt attribute can be read by screen readers.
alt attribute เคी value เคो screen readers
The value of the alt attribute can be read by screen readers. This way, someone "listening" to the webpage, e.g. a vision impaired person, can "hear" the element.
alt attribute เคी value เคो screen readers เคชเคข़ เคธเคเคคे เคนैं। เคเคธ เคคเคฐเคน เคो เคฒोเค webpage เคो เคธुเคจเคเคฐ เคเคชเคฏोเค เคเคฐเคคे เคนैं, เคैเคธे เคि เคฆृเคท्เคि เคธे เคเคฎเคोเคฐ (vision impaired) เคต्เคฏเค्เคคि, เคตे เคเคธ element เคो เคธुเคจ เคธเคเคคे เคนैं।
Example
<img src="img_girl.jpg" alt="Girl with a jacket">
Example Image
The style Attribute
The style attribute is used to specify the styling of an element, like color, font, size etc.
style attribute เคा เคเคชเคฏोเค เคिเคธी element เคी styling เคฌเคคाเคจे เคे เคฒिเค เคिเคฏा เคाเคคा เคนै, เคैเคธे color, font, size เคเคฆि।
Example
<p style="color:red">This is a paragraph.</p>
Example Image
The lang Attribute
The language of the document can be declared in the <html> tag. The language is declared with the lang attribute.
Document เคी language เคो <html> tag เคฎें declare เคिเคฏा เคा เคธเคเคคा เคนै। Language เคो lang attribute เคी เคฎเคฆเคฆ เคธे define เคिเคฏा เคाเคคा เคนै।
Declaring a language is important for accessibility applications (screen readers) and search engines:
Language declare เคเคฐเคจा accessibility applications (screen readers) เคเคฐ search engines เคे เคฒिเค เคฎเคนเคค्เคตเคชूเคฐ्เคฃ เคนोเคคा เคนै।
<!DOCTYPE html> <html lang="en-US"> <body> ... </body> </html>
The first two letters specify the language (en). If there is a dialect, add two more letters (US).
เคชเคนเคฒे เคฆो letters language เคो เคฌเคคाเคคे เคนैं (en)। เค เคเคฐ dialect เคนो, เคคो เคฆो เคเคฐ letters เคोเคก़ เคฆिเค เคाเคคे เคนैं (US)।
The title Attribute
Here, a title attribute is added to the <p> element. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph:
เคฏเคนाँ title attribute เคो <p> element เคฎें เคोเคก़ा เคเคฏा เคนै। เคเคฌ เคเคช paragraph เคชเคฐ mouse เคฒे เคाเคคे เคนैं, เคคो title attribute เคी value tooltip เคे เคฐूเคช เคฎें เคฆिเคाเค เคฆेเคคी เคนै।
Example
<p title="I'm a tooltip"> This is a paragraph. </p>
We Suggest: Use Lowercase Attributes
The HTML5 standard does not require lowercase attribute names.
HTML5 standard เคฎें lowercase attribute names เคเคฐूเคฐी เคจเคนीं เคนैं।
The title attribute can be written with uppercase or lowercase like title or TITLE.
title attribute เคो uppercase เคฏा lowercase เคฆोเคจों เคคเคฐเคน เคธे เคฒिเคा เคा เคธเคเคคा เคนै เคैเคธे title เคฏा TITLE।
UPCISS recommends lowercase in HTML, and demands lowercase for stricter document types like XHTML.
UPCISS HTML เคฎें lowercase use เคเคฐเคจे เคी เคธเคฒाเคน เคฆेเคคा เคนै, เคเคฐ XHTML เคैเคธे stricter document types เคฎें lowercase เคเคฐूเคฐी เคนोเคคा เคนै।
We Suggest: Quote Attribute Values
The HTML5 standard does not require quotes around attribute values. The href attribute, demonstrated above, can be written without quotes:
HTML5 standard เคฎें attribute values เคे เคเคธเคชाเคธ quotes เคเคฐूเคฐी เคจเคนीं เคนैं। เคเคชเคฐ เคฆिเคाเคฏा เคเคฏा href attribute เคฌिเคจा quotes เคे เคญी เคฒिเคा เคा เคธเคเคคा เคนै।
Bad
<a href=https://www.upciss.com>
Good
<a href="https://www.upciss.com">
UPCISS recommends quotes in HTML, and demands quotes for stricter document types like XHTML.
UPCISS HTML เคฎें quotes use เคเคฐเคจे เคी เคธเคฒाเคน เคฆेเคคा เคนै, เคเคฐ XHTML เคैเคธे stricter document types เคฎें quotes เคเคฐूเคฐी เคนोเคคे เคนैं।
Sometimes it is necessary to use quotes. This example will not display the title attribute correctly, because it contains a space:
เคเคญी-เคเคญी quotes เคा เคเคชเคฏोเค เคเคฐूเคฐी เคนोเคคा เคนै। เคจीเคे เคฆिเค เคเค example เคฎें title attribute เคธเคนी เคธे display เคจเคนीं เคนोเคा เค्เคฏोंเคि เคเคธเคฎें space เคนै।
Example
<p title=About UPCISS>
Example Image
Single or Double Quotes?
Double quotes around attribute values are the most common in HTML, but single quotes can also be used.
HTML เคฎें attribute values เคे เคฒिเค double quotes เคธเคฌเคธे เค्เคฏाเคฆा เคเคชเคฏोเค เคिเค เคाเคคे เคนैं, เคฒेเคिเคจ single quotes เคญी เคเคชเคฏोเค เคिเค เคा เคธเคเคคे เคนैं।
Example
<!DOCTYPE html> <html> <body> <h2>Single or Double Quotes?</h2> <p>In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes:</p> <p>Move your mouse over the paragraphs below to see the effect:</p> <p title='Jk "Jitendra" UPCISS'>Jitendra with double quotes</p> <p title="Jk 'Jitendra' UPCISS">Jitendra with single quotes</p> </body> </html>
In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes.
เคुเค situations เคฎें เคเคฌ attribute value เคे เค ंเคฆเคฐ เคนी double quotes เคนोเคคे เคนैं, เคคเคฌ single quotes เคा เคเคชเคฏोเค เคเคฐเคจा เคเคฐूเคฐी เคนो เคाเคคा เคนै।
Move your mouse over the paragraphs below to see the effect:
เคจीเคे เคฆिเค เคเค paragraphs เคชเคฐ mouse เคฒे เคाเคเคฐ เคเคธเคा effect เคฆेเค เคธเคเคคे เคนैं।
Jitendra with double quotes
Jitendra with single quotes
In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes:
เคुเค situations เคฎें เคเคฌ attribute value เคे เค ंเคฆเคฐ double quotes เคนोเคคे เคนैं, เคคเคฌ single quotes เคा เคเคชเคฏोเค เคเคฐเคจा เคเคฐूเคฐी เคนोเคคा เคนै:
<p title='Jk "Jitendra" UPCISS'>
Or vice versa:
เคฏा เคเคธเคे เคตिเคชเคฐीเคค:
<p title="Jk 'Jitendra' UPCISS">
Example
<!DOCTYPE html> <html> <body> <p>In HTML, spaces and new lines are ignored:</p> <p> My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me. </p> </body> </html>
Output
In HTML, spaces and new lines are ignored:
HTML เคฎें spaces เคเคฐ new lines เคो ignore เคिเคฏा เคाเคคा เคนै।
My Bonnie lies over the ocean.My Bonnie lies over the sea.My Bonnie lies over the ocean.Oh, bring back my Bonnie to me.
HTML Display
You cannot be sure how HTML will be displayed.
เคเคช เคฏเคน เคจिเคถ्เคिเคค เคจเคนीं เคเคฐ เคธเคเคคे เคि HTML เคैเคธे display เคนोเคा।
Large or small screens, and resized windows will create different results.
เคฌเคก़ी เคฏा เคोเคी screens เคเคฐ resized windows เค เคฒเค-เค เคฒเค เคชเคฐिเคฃाเคฎ เคฆिเคा เคธเคเคคी เคนैं।
With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code.
HTML code เคฎें extra spaces เคฏा extra lines เคोเคก़เคเคฐ output เคो เคฌเคฆเคฒा เคจเคนीं เคा เคธเคเคคा।
The browser will remove any extra spaces and extra lines when the page is displayed:
เคเคฌ page display เคนोเคคा เคนै, เคคเคฌ browser extra spaces เคเคฐ extra lines เคो เคนเคा เคฆेเคคा เคนै।
Problem
This poem will display on a single line:
เคฏเคน poem เคเค เคนी line เคฎें display เคนोเคी।
The HTML <pre> Element
The HTML <pre> element defines preformatted text.
HTML <pre> element preformatted text เคो define เคเคฐเคคा เคนै।
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it preserves both spaces and line breaks:
<pre> element เคे เค ंเคฆเคฐ เคฒिเคा text fixed-width font (เคเคฎเคคौเคฐ เคชเคฐ Courier) เคฎें เคฆिเคเคคा เคนै เคเคฐ เคฏเคน spaces เคคเคฅा line breaks เคฆोเคจों เคो preserve เคเคฐเคคा เคนै।
Example
<!DOCTYPE html> <html> <body> <p>The pre tag preserves both spaces and line breaks:</p> <pre> My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me. </pre> </body> </html>
The pre tag preserves both spaces and line breaks.
<pre> tag spaces เคเคฐ line breaks เคฆोเคจों เคो preserve เคเคฐเคคा เคนै।
My Bonnie lies over the ocean. My Bonnie lies over the sea. My Bonnie lies over the ocean. Oh, bring back my Bonnie to me.
The HTML Style Attribute
Setting the style of an HTML element can be done with the style attribute.
HTML element เคी style เคो style attribute เคी เคฎเคฆเคฆ เคธे set เคिเคฏा เคा เคธเคเคคा เคนै।
The HTML style attribute has the following syntax:
HTML style attribute เคा syntax เคเคธ เคช्เคฐเคाเคฐ เคนोเคคा เคนै:
<tagname style="property:value;">
The property is a CSS property. The value is a CSS value.
property เคเค CSS property เคนोเคคी เคนै เคเคฐ value เคเค CSS value เคนोเคคी เคนै।
Example Image
Great! Now that you have learned about the HTML style attribute, the next lesson will show you how to apply background colors to HTML elements. This will help you make your web pages more colorful, readable, and visually attractive.
เค เคเคฒा เคชाเค : เค เคฌ เคเคฌ เคเคชเคจे HTML style attribute เคे เคฌाเคฐे เคฎें เคธीเค เคฒिเคฏा เคนै, เคคो เค เคเคฒे เคชेเค เคฎें เคเคช เคธीเคेंเคे เคि background color เคा เคเคชเคฏोเค เคเคฐเคे HTML elements เคा background เคैเคธे เคฌเคฆเคฒा เคाเคคा เคนै। เคเคธเคธे เคเคชเคी web pages เค เคงिเค เคธुंเคฆเคฐ, เคธाเคซ़ เคเคฐ professional เคฆिเคाเค เคฆेंเคी।

Comments