Blog

HTML, WordPress and website content III: HTML Attributes

All the HTML elements can use attributes. HTML attributes are added inside the opening tag after the tag name and they are separated from each other and from tag name by a space. Attributes provide additional information about an element. 

Attribute usually consists of attribute name and attribute value(s). Values of one attribute are closed with quotation marks and separated from each other by a semicolon:

<Tagname Attribute name=Attribute value” Attribute name=Attribute value; Attribute value>

Example:

<p style=color:red; text-align:righttitle=”Paragraph>

Usually, the attributes which can be used depends on the element they are added to. But there are some universal attributes like style (helps design the appearance of the element), and title (gives the element the title, which you can see if you go on that web page and move the cursor over titled element).

Let us take the example from the first article and add to the elements we already have there different attributes.

The HTML code:

<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body style=”background-color:lightgrey;”>
<h1 style=”text-align:center;” title=”WELCOME!”>Headline</h1>
<p style=”color:orange; font-size:300%;”>Paragraph.</p>
<p>Paragraph.</p>
</body>
</html>

Browser view:

2016-11-25-html-article-example

 

You can try it yourself (check how from first article if needed), change the values of attributes and watch, how that changes what you see in the browser window.

Loading Facebook Comments ...

Share Your Thoughts!

Copyright ©2005-. All Rights Reserved.