Sub-Attributes and Events

This Sub-Attributes in HTML providing complete information about what is an attribute and its sub-attribute, importance of sub-attribute of HTML elements, where to place sub-attribute in HTML tag, examples of sub-attributes and Event handling in HTML pages.


  • In some of the cases, every attribute may have sub-attributes to apply properties to that element.
  • The best example of sub-attributes is “events”.
  • “Event” is an action performed on the component such as…
    1.On click
    2.On mouse over
    3.On mouse out…
  • Before understanding the concept of sub-attributes, we need to work with quotes representation while using attributes, sub-attributes with values….


Single or Double quotes :

  • Double style quotes are the most common in HTML.
  • In some situations, when the attribute value itself contains double quotes, it is necessary to use single quotes.
  • for example….

<input value = ‘it’s gonna break’/ >
should be written as….
<input value = “it’s gonna break”/>


  • Same as another example….

<input value=”i say – “this is gonna be trouble” “/>
must be written as….
<input value=”i say – ‘this is gonna be trouble’ “/>
<input value=’i say – “this is gonna be trouble” ‘/>

Example code of using sub attributes in events:
  1. <html>
  2. <head> </head>
  3. <body>
  4. <img src=”a.jpg” width=”200″ onclick=”src=’b.jpg'” onmouseover=”src=’c.jpg'” onmouseout=”src=’a.jpg'”>
  5. </body>
  6. </html>

Next Topic :              Paragraph tag and Pre tag in HTML

Share this