HTML Attributes - Learn HTML Online

Latest

A simple way to Learn HTML Queries Online

HTML Attributes


  • HTML components can have characteristics 
  • Characteristics give extra data about a component 
  • Characteristics are constantly determined in the begin tag 
  • Characteristics come in name/worth sets like: name="value"


The lang Attribute 

The record Language can be pronounced in the <html> tag. 

The dialect is announced in the lang property. 

Announcing a dialect is imperative for availability applications (screen perusers) and web crawlers:

Example

<!DOCTYPE html>
<html lang="en-US">
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>

The initial two letters indicate the dialect (en). On the off chance that there is a tongue, utilize two more letters (US). 

The title Attribute 

HTML passages are characterized with the <p> tag. 

In this illustration, the <p> component has a title property.


Example

<p title="About Q2L">
Q2L is a web developer's site.
It provides tutorials and references covering
many aspects of web programming,
including HTML, CSS, JavaScript, XML, SQL, PHP, ASP, etc.
</p>

The href Attribute 

HTML connections are characterized with the <a> tag. The connection location is indicated in the href characteristic:

Example

<a href="http://www.query2learn.blogspot.com">This is a link</a>

Size Attributes 

HTML pictures are characterized with the <img> tag. 

The filename of the source (src), and the span of the picture (width and stature) are all given as traits

Example

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

The picture size is determined in pixels: width="104" implies 104 screen pixels wide. 

You will take in more about pictures and the <img> tag later in this excercise. 

The alt Attribute 

The alt trait determines an option content to be utilized, when a HTML component can't be shown. 

The estimation of the trait can be perused by "screen perusers". Thusly, somebody "tuning in" to the website page, i.e. a visually impaired individual, can "listen" the component.

Example

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

We Suggest: Always Use Lowercase Attributes 

The HTML5 standard does not oblige lower case characteristic names. 

The title characteristic can be composed with upper or lower case like Title and/or TITLE. 

W3C suggests lowercase in HTML4, and requests lowercase for stricter archive sorts like XHTML. 

Note Lower case is the most well-known. Lower case is less demanding to sort. 

At W3Schools we generally utilize lower case characteristic names. 

We Suggest: Always Quote Attribute Values 

The HTML5 standard does not oblige cites around characteristic qualities. 

The href characteristic, exhibited above, can be composed as:

W3C suggests cites in HTML4, and requests cites for stricter record sorts like XHTML. 

Now and again it is important to utilize cites. This won't show effectively, in light of the fact that it contains a space:

Utilizing quotes are the most widely recognized. Precluding quotes can create slips. 

At W3Schools we generally utilize cites around property estimations. 

Single or Double Quotes? 

Twofold style quotes are the most widely recognized in HTML, however single style can likewise be utilized. 

In a few circumstances, when the property estimation itself contains twofold quotes, it is important to utilize single quotes:

Example

<p title='John "ShotGun" Nelson'>
Or vice versa:

Example

<p title="John 'ShotGun' Nelson">

HTML Attributes

Below is an alphabetical list of some attributes often used in HTML:
AttributeDescription
altSpecifies an alternative text for an image
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)
valueSpecifies the value (text content) for an input element.

No comments:

Post a Comment