XHTML Getting Started Tutorial: XHTML Tags

XHTML Getting Started Tutorial: XHTML Tags
Introduction to XHTML tags <br />Perhaps you have noticed in the previous section that the biggest difference between XHTML files and ordinary plain text files is some things contained in "<>", such as <body>. We call them tags. Usually XHTML tags appear in pairs, such as <html></html>. You can see that they only differ by one "/". We call tags like <html> without "/" start tags, and its corresponding </html> with "/" is called end tags. The end tag and the start tag only differ by one "/" symbol. Of course, XHTML also has some tags that do not appear in pairs, and they have no termination tags. We call such tags "empty tags". The content of the empty tag will be mentioned later in the tutorial. About case <br />Previous versions of HTML tags are not case sensitive. For example, the tag <HTML> and the tag <html> are equivalent. In XHTML, all tags are in lowercase. In order to make your website comply with XHTML standards, you should develop a good habit of using lowercase letters for all tags when making web pages. The role of XHTML tags (elements)
Open the html file saved in the previous tutorial. Change "This is my first webpage." in the sixth line to "This is my first <b>webpage</b>.", save the changes and browse the webpage again. You will find that the word "webpage" has become bold, the effect is as follows:
This is my first web page .
The difference is obvious. The word "web page" becomes bold because it is "wrapped" in the tags <b></b>. The <b> tag means bold, and it only affects the content it contains. This is how XHTML tags work. We call the content "enclosed" by a tag an element. In this example, the two words "webpage" are the elements of the <b> tag. Tag attributes
<hr size="1">
We can set some attributes for XHTML tags. Please pay attention to the horizontal line above. Its original code is: <hr />. In XHTML, the <hr> tag is a horizontal dividing line. We can add an attribute "size" (i.e. the size of the dividing line) to this dividing line, and its attribute value is 1. Then its complete code is:
<hr size="1" />
Similarly, the method of adding attributes to other XHTML tags is to add: attribute = "attribute value" in the start tag of the tag. Note that attribute values ​​must be enclosed in quotation marks. Either single or double quotes are acceptable, but double quotes are more commonly used.
The format for adding attributes: <starting tag attribute="attribute value"> Example -> <table border="none">
Note: There are two levels of standards for ordinary XHTML files (excluding framework standards) - transitional standards and strict standards. The transitional standard is mainly aimed at webmasters who are accustomed to using HTML to develop websites. The above code is legal in the transitional standard, but in the strict standard, the size attribute will be considered an illegal attribute. XHTML is not only a more standardized and stricter HTML, it also advocates a way of thinking for building websites. That is to separate the content and style of the web page, which is achieved through CSS in XHTML. Therefore, we recommend that you use strict XHTML standards and leave the task of defining styles entirely to CSS. (Issues about XHTML standards will be introduced in later tutorials) Empty tags Perhaps you have noticed that here we did not write the dividing line tag as symmetrical <hr></hr>, but as <hr />. In fact, this is exactly the unpaired tag we mentioned in the previous tutorial. It only has a start tag <hr> but no end tag </hr>. Since it has no elements, we call such a tag an empty tag. So why do we write <hr /> instead of simply <hr>? This writing format is to meet the rule in XHTML that any tag needs to be "closed". We call the method of adding "/" at the end of the start tag self-closing of the tag (or self-closing, self-termination, etc., whatever you like).
The self-closing method for all empty tags is the same, that is, add a space and a backslash "/" before the ">" symbol of the start tag. The space is not required, but some browsers cannot recognize <hr/> and can only recognize <hr />. This is why we add spaces. (I have not encountered any incompatible browsers so far)

<<:  Implementation steps for installing java environment in docker

>>:  MySQL data types full analysis

Recommend

Detailed explanation of JavaScript's Set data structure

Table of contents 1. What is Set 2. Set Construct...

Postman automated interface testing practice

Table of contents Background Description Creating...

Kali Linux Vmware virtual machine installation (illustration and text)

Preparation: 1. Install VMware workstation softwa...

Some useful meta setting methods (must read)

<meta name="viewport" content="...

Introduction to CSS style classification (basic knowledge)

Classification of CSS styles 1. Internal style --...

Web form creation skills

In fact, the three tables above all have three ro...

Nine advanced methods for deduplicating JS arrays (proven and effective)

Preface The general methods are not listed here, ...

Three BOM objects in JavaScript

Table of contents 1. Location Object 1. URL 2. Pr...

Summary of MySQL ALTER command knowledge points

When we need to change the table name or modify t...

HTML table markup tutorial (4): border color attribute BORDERCOLOR

To beautify the table, you can set different bord...

React error boundary component processing

This is the content of React 16. It is not the la...

Making a simple game engine with React Native

Table of contents Introduction Get started A brie...

Java+Tomcat environment deployment and installation process diagram

Next, I will install Java+Tomcat on Centos7. Ther...

Introduction to several ways to introduce CSS in HTML

Table of contents 1. Embed CSS styles directly in...