HTML5 brings us back to the style of a decade ago, when it was common practice to leave some tags unclosed, write values without quotes, and optionally type tags in upper or lower case. This freedom does not mean that any rules should be ignored; correct nesting of tags and insertion of required elements should still be observed. Moving away from the rigid syntax of XHTML allows you to focus on the content of the site, and not on complying with empty formalities, most of which cause irritation due to their insignificant meaning and unnecessaryness.
HTML elementsThe basic building block of a web page is an element. They can be divided according to different criteria, for example, by type or purpose.
Items by typeEmpty elements
These include elements that do not have a closing tag: , ,
,
,
,
,
,
,
,
,
,
,
,
,
,
.
Designed to output scripts or styles that have a syntax other than HTML: , .
RCDATAThese elements can contain any text or special characters, with the exception of non-standard special characters called ampersands, for example: or &T. This group of elements includes and.
Foreign elementsElements related to MathML or SVG.
Regular elementsAll other elements that are not included in the previous groups.
Elements by purposeRoot element
Element.
Document metadata, as well as the elements that are located inside it.
ScriptsScripts allow you to add interactivity to a web page; this group includes elements that control scripts.
Structural elementsElements that control the main sections of a web page, such as , , , , etc.
Content GroupingElements framing text, lists, images.
TextElements that change the appearance of the text, for example, making it bold or italic, as well as highlighting the text by meaning - abbreviation, quote, variable, code, etc.
ReviewElements and showing edits in a document.
Embedded ContentElements inserted onto the page in the form of different objects - images, video, audio, etc.
Tabular dataElements for creating and managing the appearance of tables.
FormsForms are one of the important elements of any website and are designed for the exchange of data between the user and the server. This group includes elements for creating a form and its fields.
Interactive elementsSpecial widgets with which the user can obtain additional information or control.
LinksElements And .
Such grouping is conditional and can take on a different form, because the same elements can belong to different groups.
TagsTags are used to indicate the beginning and end of an element. Inside tags there can be attributes with their own values that expand the capabilities of the tags, as well as the content (Fig. 1).
Rice. 1. Tag with href attribute
The closing tag is similar to the opening tag, but contains a slash (/) inside angle brackets.
Empty elements have no closing tag and no content (Figure 2).
Rice. 2. Empty tag
Tag attributes expand the capabilities of the tags themselves and allow you to flexibly manage various settings for displaying web page elements. The total number of attributes is quite large, but their values, as a rule, can be grouped into different types, for example, specifying color, size, address, etc. For example, an element adds an image to the web page, and we indicate the address of the graphic file through the src attribute.
Doctypeis intended to indicate the type of the current document - DTD (document type definition, description of the document type) so that the browser understands which version of HTML it is dealing with. If the doctype is not specified, browsers go into compatibility mode, in which many HTML5 features do not work, and errors occur with document display.
The doctype is not case sensitive and contains only two words:
This is the key element and is usually located in the first line of code.
CommentsSome text can be hidden from being shown in the browser by making it a comment. Although this text will not be seen by the user, it will still be transmitted in the document, so if you look at the source code, you can discover hidden notes.
Comments are needed to make your own entries in the code that do not affect the appearance of the page. They start with the tag. Anything between these tags will not be displayed on the web page.
Optional TagsIf a tag is not listed, it does not mean that it is not represented at all. There are certain rules that allow you not to write some tags. In table 1 shows tags that can be omitted and the condition under which this occurs.
If there are other elements inside. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If empty and also contains something other than a space or a comment. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If an element is followed by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If an element is followed by or . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If the element is followed by , or it is the last one of the parent. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
If the element is followed by , , , , , , , , , , ,..., , , , , , , , , , ,
If the opening tag contains one or more attributes, then the tag must be specified. Due to the fact that many tags may not be specified, because... they are implied by default, any document is reduced to the following parts. You can insert any number of spaces or comments before and after the doctype. Thus, the doctype does not have to be on the first line of code. Example 1 shows the minimal HTML code to display a traditional greeting. Example 1: Minimal HTML HTML5 IE Cr Op Sa Fx Hello World! A byte order mark consists of a U+FEFF character code at the beginning of the document, where it is used to determine the encoding. It is recommended to remove this symbol, since its presence leads to errors in displaying the document in some browsers. To do this, you can use the Notepad++ editor, in the “Encodings” menu, select “Encode in UTF-8 (without BOM)” (Fig. 3). Rice. 3. Select encoding useful links
indicates which HTML standard your Web page is written according to.
So, there are several doctypes (strict and transitional, for HTML and XHTML). Which standard to choose is the question. HTML and XHTML StandardsHTML - standard language Web document markup. In HTML 4.01 and HTML5 appearance page is separated from its content. Content and structure (headings, paragraphs, links) are specified in HTML. The design (alignment, fonts, colors) is specified by CSS styles. For example, the align tag and attribute have been deprecated. XHTML is an extensible Web document markup language based on XML. The XHTML standard is a list of differences between HTML 4.01 and XHTML. The advantages of the XHTML language are not the strictness of the syntax, but the ability to come up with your own tags. However, on July 2, 2009, the World Wide Web Consortium (W3C) announced the termination of work on XHTML 2.0, considering the concept of XHTML to be incorrect. A group of programmers switched to working on the HTML5 standard. And although the HTML5 standard has not yet been approved, many sites have already been written on it. Anyone wondering when HTML5 will be finished can check out the original sources: The official version of the HTML5 standard is located at: www.w3.org/TR/html5/ Let's make a choice. It's not difficult to do: you shouldn't use the XHTML standard if you don't intend to extend the HTML language. We won’t dwell on!DOCTYPE, intended for documents using frames: the day before yesterday. The next question is: which syntax to choose - strict or transitive? Strict and transitional HTML 4.01 syntaxTransition syntaxes exist to ease the transition to a new standard. They will skip a lot of what strict syntax would consider errors. It’s easier to understand what’s what here with an example. First, let's set the strict syntax. Strict syntax Validity check Validity checkin red. Compliance of HTML code with the declared standard is called validity, and checking for this compliance is called validation. To track layout errors, install the FireFox Html Validator add-on. Let's open our page at FireFox browser, move the mouse over the validator sign: Double clicking on the validator sign will give a detailed list of errors: Let's change!DOCTYPE to transition syntax: Transitional syntax Validity check Validity checkSome of the text needed to be highlighted in red. Launch FireFox. No errors: Everything seems fine. Maybe we should stop there? My advice: do a valid layout either in accordance with the strict syntax of HTML 4.01, or directly in HTML5. HTML should be used for its intended purpose, and the design should be left to CSS. In addition, if the site has a valid layout, but it does not display correctly in any browser, then this is definitely a browser problem. New versions of the browser will better comply with the standard and not make mistakes in interpreting valid code. If a complex layout is implemented in an invalid way, then there is no guarantee that new versions of browsers will not crumble it into pieces. Don't be tempted by the loyalty of transitional syntax, only strict compliance with standards! Why is a valid layout needed?It would seem, why bother? After all, browsers often correct small layout flaws automatically, and the site works absolutely fine. But these small, practically unnoticeable errors are nevertheless noticed search engines. Even one missing tag - this is a minus in assessing the quality of the site.It is precisely because of the ability of search engines to notice any shortcomings in the HTML code that it is recommended to maintain the validity of the layout. In addition, when checking the code for validity, you can find, along with minor flaws, also serious mistakes, which were not noticed before. HTML tags are the basis HTML language. Tags are used to delimit the beginning and end of elements in markup. Each HTML document consists of a tree of HTML elements and text. Each HTML element is identified by a start (opening) and ending (closing) tag. The opening and closing tags contain the name of the tag. All HTML elements are divided into five types:
The table provides a complete list of elements supported by HTML4 and HTML5. Experimental and legacy tags are excluded. Elements added to the HTML5 specification are highlighted in teal. Complete list of HTML elements
|