Attributes provide additional information about HTML elements.


  • 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"

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.


<p title="I'm a tooltip">
This is a paragraph.
</p>


href Attribute:-


HTML links are defined with the <a> tag. The link address is specified in the href attribute.



<a href="https://www.w3schools.com">This is a link</a>


Size Attributes:-

HTML images are defined with the <img> tag. The filename of the source (src), and the size of the image (width and height) are all provided as attributes.

<img src="s1school.jpg" width="104" height="142">

The image size is specified in pixels: width="104" means 104 screen pixels wide. 
You will learn more about images and the <img> tag later in this tutorial.


alt Attribute:-

The alt attribute specifies an alternative text to be used, when an image cannot be displayed. The value of the attribute can be read by screen readers. This way, someone "listening" to the webpage, e.g. a blind person, can "hear" the element.

<img src="s1school.jpg" alt="s1school.jpg" width="104" height="142">


suggestion:- Use Lowercase Attributes 

The HTML5 standard does not require lowercase attribute names. The title attribute can be written with uppercase or lowercase like title or TITLE

At s1school we always use lowercase attribute names.

Suggestion:-  Quote Attribute Values

The HTML5 standard does not require quotes around attribute values. The href attribute,
demonstrated above, can be written as:- 


<a href=https://www.s1school.blogspot.com>


Sometimes it is necessary to use quotes. This example will not display the title attribute correctly, because it contains a space. Using quotes are the most common. Omitting quotes can produce errors. 
At W3Schools we always use quotes around attribute values.

<p title=About s1school>




what is Single or Double Quotes?

Double quotes around attribute values are the most common in HTML, but single quotes can also be used.In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes:-

<p title='WEb "designer" ali'>

or 

<p title="web 'designer' ali">



HTML Attributes:-


AttributeDescription
altSpecifies an alternative text for an image, when the image cannot be displayed
disabledSpecifies that an input element should be disabled
hrefSpecifies the URL (web address) for a link
idSpecifies a unique id for an element
srcSpecifies the URL (web address) for an image
styleSpecifies an inline CSS style for an element
titleSpecifies extra information about an element (displayed as a tool tip)

A complete list of all attributes for each HTML element, is listed in our: attributes reference.




IF you have any question about this lecture you can comment blow. feel free to contact me.
you can also Visit my YouTube channel by clicking on this Link YouTube Channel.

0 comments:

Post a Comment

Thanks

 
Blogger Templates1 school © 2013. All Rights Reserved. Powered by Blogger
Top