Home  >  Article  >  Web Front-end  >  HTML Basics Tutorial: Learn to Master HTML Elements

HTML Basics Tutorial: Learn to Master HTML Elements

黄舟
黄舟Original
2016-12-26 15:15:341707browse

HTML documents are text files composed of HTML elements.

HTML elements are defined using HTML tags.

HTML tags

HTML tags are used to mark HTML elements.

HTML tags are surrounded by < and > symbols.

These surrounding symbols are called.

HTML tags appear in pairs. For example and.

The text between the start tag and the end tag is the content of the element.

HTML tags are not case-sensitive and have the same effect as .

HTML Elements

Remember the example from the previous section:

This is my first page. This text is bold.

This is an HTML element:

This text is bold.

This HTML element starts with a start tag.

The content of this element is: "This text is bold.".

This HTML element is terminated by a closing tag. The purpose of the

tag is to define an HTML element that is displayed in bold.

This is also an HTML document:

This is my first page. This text is bold.

This HTML element starts with a tag and ends with a tag. The function of the

tag is to define the HTML element that contains the body in the HTML file.

Why do we use lowercase tags?

We just mentioned: HTML tags are not case-sensitive: they have the same effect as . When you surf the web, you will find that most tutorials use uppercase HTML tags in their examples. And we always use lowercase. What's the reason?

If you want to be ready for the next generation of HTML, you should use lowercase tags. The World Wide Web Consortium (W3C) standard is that it is recommended to use lowercase tags in HTML 4, and in XHTML (the next generation of HTML), lowercase tags must be used.

Tag attributes

Tag can have attributes. Attributes provide additional information to HTML elements on your page.

As mentioned earlier, tags are used to define the body element of the page. You can tell the browser to display the page's background color as red by adding a bgcolor attribute, like this: .


is used to define an HTML table. You can tell the browser to display a table without borders by adding a border attribute: .


Attributes consist of an attribute name and a value, like this: name="value". The

attributes should be added to the start tag of the HTML element.

Single quotes or double quotes?

Attribute values ​​should be enclosed in quotation marks. Normally double quotes should be used, but single quotes are fine.

But in some cases, such as the attribute value itself contains double quotes, you must use single quotes, for example:

name='John"ShotGun"Nelson'

The above is the basic HTML tutorial: learn to master the content of HTML elements. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn