Thursday, December 11, 2014

Diffferece between span and label in HTML




What is difference between label and spna in HTML? for example:
<span id="myid"></span>
or
<label id="myid"></label>

The <span> tag is used to group inline-elements in a document.  such as
<p>This car is  <span style="color:blue">blue</span> </p>
 
 A label is used in combination with a form input element. In some browsers the label can be clicked to activate the input element.
 

Span

The <span> tag is used to group inline-elements in a document.
The <span> tag provides no visual change by itself.
The <span> tag provides a way to add a hook to a part of a text or a part of a document.

Label

The <label> tag defines a label for an element.
The <label> element does not render as anything special for the user. However, it provides a usability improvement for mouse users, because if the user clicks on the text within the <label> element, it toggles the control.
The for attribute of the <label> tag should be equal to the id attribute of the related element to bind them together.
 

No comments:

Post a Comment