HTML tags can contain one or more attributes. Attributes
are added to a tag to provide the browser with more information about
how the tag should appear or behave. Attributes consist of a name and a value separated by an equals (=) sign.
Example
Consider this example:| Code | Result |
|---|---|
|
|
Do you like my background color?
|
style="background-color:orange", tells the browser to style the <p> element with a background color of orange.The browser knows to make the background color orange because we are using standard HTML tags and attributes (along with standard Cascading Style Sheets code) for setting the color.
Another Example
Here's another example of adding an attribute to an HTML tag. In this example, we use the <a> tag to create a hyperlink to a web page at another website.| Code | Result |
|---|---|
|
|
HTML links |
| Attribute | Description | Possible Values |
|---|---|---|
| class | Used with Cascading Style Sheets (CSS) | (the name of a predefined class) |
| style | Used with Cascading Style Sheets (CSS) | (You enter CSS code to specify how the way the HTML element is presented) |
| title | Can be used to display a "tooltip" for your elements. | (You supply the text) |
You will see more attributes being used as we cover off some of the more advanced HTML elements.






0 komentar:
Posting Komentar