4.4. Introduction to HTML: basic structure, tags and attributes: Attributes in HTML

Página 8

4.4. Introduction to HTML: Basic structure, tags and attributes

HTML, which stands for HyperText Markup Language, is the standard markup language for creating web pages. It is used to describe the structure and content of a web document, and is made up of a series of elements or 'tags' that the browser interprets to display the web page as the developer intended.

Basic structure of an HTML document

A basic HTML document starts with the doctype , which tells the browser which version of HTML the document is using. The actual HTML document begins and ends with the <html> and </html>.

Within these tags, we have two main parts: the 'head' (<head> and </head>) and the 'body' (<body> and </body>). The 'head' contains information about the document that is not displayed in the browser window, such as the page title (which is displayed in the browser's title bar or page tab) and links to CSS and JavaScript files that can be used on the page. The 'body' contains the actual content of the page that is displayed in the browser.

Tags in HTML

Tags are used to mark elements in an HTML document. They are usually composed of an element name surrounded by angle brackets. Most HTML elements have an opening tag and a closing tag, with the element's content contained between the two.

For example, a paragraph in HTML is marked with the tag <p> (the opening tag) and the </p> (the closing tag). Anything between these two tags is treated as a paragraph by the browser and is displayed accordingly.

There are many different tags available in HTML, each with a specific purpose. Some of the most common tags include <h1> to <h6> for headers, <p> for paragraphs, <a> for links, <img> for images and <div> and <span> for generic content divisions.

Attributes in HTML

Attributes provide additional information about an HTML element. They are always specified in the opening tag and usually come in name/value pairs. For example, the link tag <a> usually includes the 'href' attribute, which specifies the URL the link should point to.

Other common attributes include 'src' (which specifies the source of an element, such as an image or video), 'alt' (which provides alternative text for an element, to be displayed if the element cannot be rendered ) and 'style' (which can be used to add CSS directly to an element).

Attributes are an important part of HTML because they allow you to customize the behavior and appearance of an element to suit your needs. However, they should be used sparingly, as excessive use of attributes can make HTML code difficult to read and maintain.

In short, HTML is a powerful and flexible markup language that allows you to create a wide variety of web pages. By understanding the basic structure of an HTML document, as well as the use of tags and attributes, you can start creating your own web pages and become an effective front-end developer.

Now answer the exercise about the content:

What is the function of the 'head' tag in an HTML document?

You are right! Congratulations, now go to the next page

You missed! Try again.

Next page of the Free Ebook:

94.5. Introduction to HTML: Basic Structure, Tags and Attributes: Heading Tags

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text