HTML Attributes

Let's edit our basic HTML:

<!DOCTYPE html>
<html>
<head>
  <title>My Page</title>
</head>
<body>
  Hi, here is some text.
</body>
</html>

and turn the background green. We can add a style attribute inside the <body> tag:

<body style="background-color: green">

The page then looks like this:

web page with green text

Attributes provide useful information that relates to the HTML element. For example, when you create a link in HTML, you provide an attribute that tells the browser where to send the user when the user clicks on the link.

Next: How to add a line break in HTML

Comments

Leave a comment

What color are brown eyes? (spam prevention)
Submit
Code under MIT License unless otherwise indicated.
© 2020, Downranked, LLC.