Attributes and Hyperlinking
Get an understanding of HTML attributes and how they can be linked to other HTML pages.
We'll cover the following...
HTML attributes
HTML attributes provide additional information about an HTML element. Attributes can be considered as properties of the element. An element may have a single attribute, many attributes, or no attributes at all.
Let’s take a look at an example heading with a title
attribute:
<h2 title="This is a subheading">Hello, World!</h2>
Attributes are placed in the opening tag, with a space after the element declaration (or another attribute, if there are multiple) and are defined using the following format:
<tagName attribute_name="attribute_value"></tagName>
The attribute name is always followed by an =
sign and the attribute value is always wrapped in quotation marks. There are no spaces between the attribute name, =
sign, and the attribute value.
Test your understanding
Another type of HTML attribute is the style
property, which can be used to give an element a custom style. How would we define a paragraph element with both title and style attributes?
<ptitle="My Paragraph"style="color:blue">Hello, World!</p>
<p title="My Paragraph"style="color:blue">Hello, World!</p>
<p title="My Paragraph" style="color:blue">Hello, World!</p>
<p>Hello, World!</p title="My Paragraph" style="color:blue">
Exercise
Create a top-level header that has a ...