HTML attributes: types and uses. HTML reference

Table of contents:

HTML attributes: types and uses. HTML reference
HTML attributes: types and uses. HTML reference

Hypertext Markup Language HTML has a wide variety of tags to make your site look nice. Over time, a novice web designer realizes that just marking up text is not enough. Among modern web pages come across real works of art. Website builders play with text fonts, sizes, and element positions as they please. It is HTML attributes that allow you to assign certain properties to tags, supplement and change their content.


Attributes are written in the opening tag and consist of two parts. The first is the name, which is written with a space after the tag name. The second part is the value of the attribute, which is indicated after the "=" sign and enclosed in double quotes. HTML attributes are different for different tags. Most of them perform different tasks, but there are a few common attributes. They can be applied to many elements of a web page.

HTML attributes
HTML attributes

One tag can contain multiple attributes. They are written one after the other and are located exclusively in the opening tag. The closure cannot contain any attributes.

HTML Universal Element Attributes

There are several attributes that can be applied to different tags. They are responsible for the position of the element on the page, its height, width, color and other visual effects. One of these is Align, which can be set to right, left, or center. It aligns the tag horizontally, so it can be useful for most markup elements. Valign does the same but vertically. It can be assigned the values top, bottom and middle. The next universal attribute is bgcolor, which is responsible for the background color. Its value is indicated as a numeric code representing one of the RGB colors. An image can become a background by using the background attribute.

HTML reference
HTML reference

An element can be given a name that will be displayed when hovering over it. To do this, use the title attribute, the value of which is determined by the user. There is another similar attribute that is used to create a unique element identifier. This attribute is called id and allows the site creator to style the specific tag. To work with CSS, use an attribute called class, which will be treated as the name of a tag in cascading style sheets. The width of a table, image, or cell can be set using the width attribute, and the height can be set using the height attribute. There are alsoother global attributes, but they are unlikely to be needed by a beginner.

HTML tag attributes

There are several useful attributes that affect the entire HTML document. Some of them can be applied to individual fragments, such as lang. This attribute specifies the language of the text on the web page. Why is this necessary if the site looks correct and without specifying the language? In fact, some characters are displayed differently for different languages. For example, quotes for English look like this - “…”, and for Russian like this “…”. In some cases, the use of lang is necessary, but often you can do without it. The xml:lang attribute performs a similar function, but is used in XHTML documents.

HTML tags and attributes
HTML tags and attributes

You can set not only the language of the document, but also a special hint. It pops up when you hover over a web page and is set using the title attribute. There is one more attribute for the tag that specifies the namespace of the XHTML document. Its name is xmlns. The value of this attribute is a link - No other values can be assigned to it.

CSS font options

Some HTML attributes are used to specify the font in CSS. The first one is called font-family. It specifies a list of fonts that will be used in any element. The value of this attribute is the name of the font. The selected font can be changed using font-style. This option can make the font italic or make it italic. Values - normal (normal), italic (italic) andoblique (oblique). The next useful attribute for cascading style sheets is called font-variant. With it, you can highlight the text in special capital letters. font-variant has only two values - normal and small-caps.

global attributes
global attributes

Another attribute for a font is called font-weight and is responsible for the thickness of the text. It can be set to normal if you want letters of standard thickness. Light text should be set to lighter, and bold should be set to bold. Bold text is indicated in this attribute as bolder. You can set the character thickness in numerical format. In this case, 100 is the thin font and 900 is the thickest. The font-size attribute sets the font size. It can be expressed in points (pt), pixels (px), and percentages (%). To get a standard font size, set this attribute to normal.

Text properties

With the proper use of attributes, you can change not only the font, but the entire text. Line spacing can be set using the line-height attribute. This parameter is set by specifying an exact value in pixels, a percentage, or a multiplier. This attribute is set to normal. You can add beautiful text effects if needed. There is a text-decoration attribute for this. Set it to none if you want to remove all decoration effects. Underline will add an underline to the text, and overline will add a line above the text. The blink value will make the text blink, and line-through will cross it out.

One moreuseful attribute is text-transform. If you assign the value capitalize to it, then the text will begin with capital letters. A value of uppercase will make all letters uppercase, while lowercase will make them all lowercase. To remove all effects, set this attribute to none. Text-indent will help you set the indentation of the first line. It can be assigned a value in pixels or percentages. Text-align is an attribute responsible for text alignment. Possible values for this parameter are left, right, center, justify. Don't try to remember the main attributes right away, the HTML reference will help you at the initial stage.

HTML tags and attributes

If you decide to master the art of creating web pages, you will have to memorize a lot of tags. HTML attributes are equally important, because without them it is impossible to create a website. Skillful use of these language components will allow you to create decent web pages.

global attributes
global attributes

Some tags have their own unique attributes that are difficult and impractical to remember. Therefore, even experienced web designers keep an HTML reference handy. There is nothing shameful in this, because you never know which tag or attribute you will need today. However, it's a good idea to remember global attributes that can be applied to most existing elements. To consolidate the material, try to apply the acquired knowledge in practice. Master the HTML language, and it will bring you a lot of positive emotions, as well as a solid income.

Popular topic

Editor's choice

  • The Psijic Order from The Elder Scrolls - who are they?
    The Psijic Order from The Elder Scrolls - who are they?

    The Psijics are the name of a mysterious and ancient Order from the Elder Scrolls game universe. Its members practice magic and are notorious for being at odds with the Thalmor. Even more interesting information about the Psijic Order can be found in today's guide

  • Three easy ways to turn off notifications in Viber
    Three easy ways to turn off notifications in Viber

    "Viber" today is one of the most popular and widespread instant messengers. Sometimes a situation arises that the sound of constantly incoming messages bothers or distracts a person from important matters. How to turn off notifications in Viber? The article presents three of the simplest and easiest ways to do this, and they will help you set the silent mode on both Android and iOS

  • How to advertise on Instagram yourself?
    How to advertise on Instagram yourself?

    One of the most effective methods of website promotion and business development at the moment is advertising on social networks. Social networks, where people actively communicate, are more willing to pay attention to useful posts, join groups, like posts and make reposts, are an almost inexhaustible source of traffic. A properly built advertising campaign will allow you to get new customers, keep the attention of existing ones and again win over those who were dissatisfied with the service

  • Google - what is it?
    Google - what is it?

    The article talks about the multidisciplinary corporation Google. Its services and the company's work as a device manufacturer are considered

  • How to remove a user from important friends on VKontakte: all ways
    How to remove a user from important friends on VKontakte: all ways

    Important friends of "VKontakte" are determined automatically. When friends, family, and a loved one appear first on the list, this is convenient. But relationships can change for various reasons, and the need to constantly see a person’s page may disappear. In this article, we will tell you how to remove from important VKontakte friends those users whom you do not want to see at the top of the list