Web Design - Web Authoring / Intro to HTML: Formatting Text

Sections:  Introduction  |  Section 1  |  Section 2  |  Section 3
Section Two:  Part A  |  Part B  |  Part C  |  Part D  |  Part E  |  Part F  |  Part G  |  Part H  |  Part I

Attributes

Attributes

As you have learned, HTML is a collection of tags you use to ‘markup’ plain text for viewing in a web browser. Many HTML tags can have attributes added to them. Attributes provide extra information about the tag as well as extend a tag's display and functionality. For instance, attributes:

  • Can be added to most (but not all) HTML tags.
  • Are always listed in the opening tag.
  • Are listed as name/value pairs – represented as: name=”value”.
  • Can be added with other attributes, to the same tag.

As we know, the purpose of a browser (e.g., Chrome, IE, Firefox, Safari, etc.) is to read HTML documents and display webpages as marked up with HTML tags. The browser does not display the HTML tags, but uses them to determine how to display the webpage.

Attributes provide additional information about HTML elements.For instance, consider the <html> tag, one of our terrific ten tags. A common attribute added to the <html> tag is the lang="" attribute. The lang="" attribute is used to declare the language in which a webpage is written. There are various reasons to declare the language. It not only assists search engines and browsers by improving the quality of search results based on the user's linguistic preferences, but for non-text readers using assistive technology, declaring the language at the beginning of the document provides a higher quality translation.

Hence, we will modify the opening html tag to include the lang="" attribute in all our webpages. The value of the of the attribute appears between the quotes. The value is "en-US". So:

<html lang="en-US">

tells the browser to get ready to display a HTML webpage, and to use the United States' style of English to understand the markup.

Next Next

© All rights reserved.