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">
HTML Example Image

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>

HTML Example Image

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>

HTML Example Image

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 เคนोเคคी เคนै।

HTML Example Image

Example Image


๐Ÿ“š Continue Learning – Next Topic

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

Popular posts from this blog

Tally Prime Edit Log – Company Creation, GST Enable, Purchase & Sales Entry PDF Download

HTML Introduction HTML Quotation HTML Colors HTML Links HTML Images HTML Tables HTML Lists Block & Inline Class Attribute ID Attribute HTML Iframes HTML Forms

HTML tags in Hindi – Complete list of basic HTML tags with easy explanation for beginners.