HTML Sub Attributes

Previous
Next

Sub attributes:

  • In some of the cases, every attribute may have sub attributes to apply properties to that element.
  • Best example of sub attributes is “events”.
  • “event” is an action performed on the component such as…
    • On click
    • On mouse over
    • 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’ “/>

or

  • <input value=’i say – “this is gonna be trouble” ‘/>

Example code of using sub attributes in events:

<html>
	<head> </head>

	<body>
		<img src="First.jpg" width="200" onclick="src='Second.jpg'" onmouseover="src='Third.jpg'" onmouseout="src='First.jpg'">
	</body>
</html>
Previous
Next

Courses Enquiry Form