HTML Hypertext Markup Language is a markup-based web design language specifically used to design and edit web pages. XHTML is HTML reshaped to adapt to XML. It is also a markup language. It can be seen as the transition from HTML to XML; XHTML requires that any element that appears in a web page should be marked.
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
What is HTML
HTML’s full name in English is Hyper Text Markup Language, which is translated into Chinese as “Hyper Text Markup Language”. It is a A markup web design language specifically used to design and edit web pages.
Hypertext Markup Language is the description language of WWW. It includes a series of tags. These tags can unify the document format on the network and connect scattered Internet resources into a logical whole. HTML text is descriptive text composed of HTML commands. HTML commands can describe text, graphics, animations, sounds, tables, links, etc.
<!DOCTYPE html> <html> <body> <h1>hello world !</h1> </body> </html>
So what does hypertext mean? Hypertext: Pages can contain pictures, links, and even non-text elements such as music and programs. Let’s recall what the role of HTML is in the project. 1. What is certain without thinking is its display function. 2. For any element on the page, we can use JS to make some animation changes to it, whether it is a change in display or a link to other places. In other words, the elements in HTML can be imagined as a portal. With just a click of the mouse, we may get more relevant content. Okay, now imagine that an HTML page is a node, connected to two HTML pages through some kind of trigger. In this way, tens of thousands of HTML pages constitute our World Wide Web.
What is XML
XML is a new language designed to self-describe information. Like HTML, XML is also a text-based markup language, but XML allows users to freely define tags to express document content with practical meaning based on the document they want to express.
What is XHTML
Extensible Hypertext Markup Language XHTML (eXtensible HyperText Markup Language) is the hypertext markup language HTML (HyperText Markup Language) as a standard redefined for XML applications.
XHTML is HTML that has been reshaped to adapt to XML. It is also a markup language; it can be seen as the transition from HTML to XML; XHTML requires that any element that appears in a web page should be marked.
XHTML is almost the same as HTML, but it is more strict than HTML. XHTML is HTML defined as XML application. It is supported by all major browsers.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>标题</title> </head> <body> <h1>XHTML</h1> </body> </html>
The difference between xhtml and html
1. XHTML elements must be nested correctly
Example:
Generally, html web pages can be "main content" This is not strict and is wrong in XHTML; the correct one is The xhtml standard must require such "main content".
2. XHTML elements must be closed
exp:
An example in HEAD, " " Tags like this are feasible in HTML, but for the sake of xhtml standards, they must be closed such as " "
For example, when using the "
" line break tag in general HTML, many people just add a "
" tag to the paragraph that needs to be broken, but in the XHTML CSS standard, it must be like this " < ;p>Paragraph text
” means that it must start with the line break tag “” before the article text field, and end with the “
” tag after the paragraph text.For example, many people use the small line break tag "br" when making html pages. Many people don't know that this tag needs to be wrapped in a closed style. For example: after a paragraph of text, a line break is required. Many CSS productions require line breaks. It would be nice to add a "
" here, but let me tell you that this is also non-standard. It will not pass during XHTML verification and must be closed with "
".
3. Tag names must use lowercase letters
In previous web pages, many tags were usually arranged in uppercase or lowercase letters, but for the sake of WEB standards, tags now require uniform lowercase letters. .
exp:
In the past, many ",
" were used in uppercase or mixed case, such as ", " or ", ". However, XHTML unified requirements require the use of " , " in lowercase.4. The XHTML document must have a root element.
means that any tag that starts with it must be ended with any tag. For example,
must start with the content and end with it. Use to close.5. You need to add alt attributes to pictures
In the past, when displaying pictures on web pages, you could add or not add alt attributes to the img tag, but now xhtml requires it. Add the alt attribute, otherwise the xhtml verification will prompt an error, even if the alt value is empty.
exp:
Error<img src="Picture address" />
Correct<img src="Picture Address" alt="Picture description" />
What are the benefits of adding alt? Answer: Adding alt can provide a text description for the image, allowing search engines to identify the content of the image, which is a good place to optimize web pages.
(Learning video sharing: Getting started with web front-end)
The above is the detailed content of What is html and xhtml. For more information, please follow other related articles on the PHP Chinese website!