Elements used in the body of an HTML document. Let's analyze this example
An HTML document consists of body text and tags. Essentially, an HTML document is a text file and you can use a regular text editor such as Notepad to create it.
HTML documents have a strictly defined structure and must begin with a tag and end with a closing tag. This pair of tags tells the browser that this is indeed an HTML document.
An HTML document consists of a header section and a body section. The headers section is enclosed between and tags and contains information about the document as a whole. In particular, this section should contain tags and , between which the title of the document is placed. Browsers use this title to fill the title bar of the browser window.
The main text is located in the body of the document, which is specified by and tags. The BGCOLOR attribute is used to change the background of the document, and the TEXT attribute is used to set the font color. The values of these attributes are a symbolic color constant or a hexadecimal number that forms the color according to the red-green-blue scheme.
The four paired tags listed define the basic structure of an HTML document. They appear or are implied in all HTML documents.
In fact, it is possible to determine the location of the main structural tags even in their absence. Therefore, if the tags , , and the corresponding closing tags are omitted, then the browser program itself will determine the place where they should be located. The tag is considered mandatory, but skipping it will not cause catastrophic consequences. However, when creating Web pages, it is not recommended to omit these tags, since it is unknown how the browser installed on the user’s computer will behave.
Paired tags affect the portion of the document between the opening and closing tags. This part of the document is considered as an element HTML language. For example, the BODY element includes an opening tag, the body of the element, and a closing tag. HTML language elements are divided into block and text. Block elements refer to paragraph-level pieces of text. Text elements describe the properties of individual phrases and smaller parts of text. When creating an HTML document, it is advisable to adhere to the following nesting rules:
elements must not intersect. If the opening tag is inside an element, then the closing tag must be inside the same element;
block elements can contain nested block and text elements;
text elements can contain nested text elements;
text elements cannot contain nested block elements.
Document title
Functional sections of the documentThe HTML language is designed to describe the functional sections of a document. In many regular documents, the main functional sections are headings and paragraphs.
HTML supports six levels of internal document headings. They are marked with tags from and to and . On a computer screen, these headings are displayed in fonts of different sizes. In accordance with the ideology of the HTML language, the text, which is essentially a heading, must be marked using one of these tags. Use formatting tags that change font size and style in in this case do not do it.
To designate regular paragraphs, use the tag
And accordingly the closing tag
. Tags that describe regular paragraphs are optional, but if they are present, browsers will clearly track the boundaries between paragraphs.To improve text readability, browsers display a blank line between paragraphs. An effective means of creating separators in text are horizontal stripes (rulers), visually dividing the document into parts. A horizontal ruler is created by the tag. This is a single tag and does not have a pair.
When creating an HTML document, keep in mind that multiple spaces between words and new lines are ignored when the document is played back by the browser.
To move to a new line without creating a paragraph, use the tag
.
Functional sections of the document
Main title
Subtitle
These lines are displayed together,
despite the fact that in the document
they are separated
from each other.
The closing paragraph tag is optional.
The paragraph start tag is more important than the actual newline.
Text after horizontal ruler
split into two lines
When creating a website, the first thing you need to imagine is how the web page is formed. This is a kind of “foundation” in website building. Therefore, before delving into more complex website creation technologies, it is recommended to have at least basic knowledge of HTML. In this lesson we will get acquainted with HTML, analyze the structure of an HTML document and practical examples Let's consolidate the acquired knowledge.
What is HTML?HTML stands for HyperText Markup Language. This language is responsible for exactly how hypertext will be displayed on site pages. Now let's figure out what hypertext is? It's no secret that a single web page can contain a lot of different types of information, be it text, some tables, graphs, videos, audio, etc. So, all this information can be called in one word - hypertext.
Note that HTML is a markup language, not a programming language. IN given language there are no logical functions and it is impossible to make any mathematical calculations on it. HTML pages have the extension .html or .htm and are processed by browsers - IE, Mozilla Firefox, Google Chrome, Yandex Chrome, Opera, etc.
Now let's figure out how the browser understands what and how to display on a web page? It's very simple. The hypertext markup language HTML has built-in commands called tags. It is by them that the browser is oriented.
HTML Document StructureAny HTML document (web page) must have a certain structure. This will avoid possible problems when opening pages in browsers. As an example, let's look at a page that contains following HTML code:
), between which the identifier (name) of the tag is written (in our example it is in), and, possibly, its parameters. The only exception to this rule is comment tags with more complex delimiters (). The names of tags, as well as their parameters, can be written in any register. For consistency, most tags in this book are written in capital letters.Majority HTML tags used in pairs, i.e. for a certain tag, let’s call it opening, the document has a corresponding closing tag. By HTML rules The closing tag is written in the same way as the opening tag, but with a / (forward slash) in front of the tag name. The only fundamental difference between paired tags is that closing tags do not use parameters.
Tags that require corresponding end tags will be called container tags. We will call everything written between the corresponding opening and closing tags the contents of the container tag. Sometimes the end tag can be omitted. For example, for a tag describing data for a table cell
There are a number of tags for which the end tags are omitted by most document authors. An example would be a list item tag
Modern browsers will in many cases format documents correctly if some end tags are omitted, but this practice cannot be recommended.
Some tags don't require end tags at all. Examples include the image insertion tag , forced line feed
, indication of the base font, etc. Often, from the very purpose of the tag, you can guess whether it needs a final one.
There are general rules for how browsers interpret tags. Unlike programming languages, in which erroneous statements lead to the issuance of corresponding messages at the compilation stage of the program and require editing, in HTML it is not customary to react to incorrect tag entries. An incorrectly written tag or its parameter should simply be ignored by the browser. This is a general rule for all browsers, which applies not only to erroneously written tags, but also to tags that are not recognized by this version of the browser. An example would be tags that were proposed and implemented for a particular browser and unknown for another. For example, a container tag that serves to provide alternative information to browsers that do not support frame structures will not be recognized by such browsers. A browser that supports frames, when it encounters a tag, will skip all the information contained in it. And a browser that is not familiar with frames will naturally not understand the tag. However, according to the above rule, this tag will simply be skipped, but all subsequent information will be displayed.
Tags can be written with parameters or attributes (from English, attribute). In this book we will use the term parameter most often. Sets acceptable parameters are individual for each tag. General rules The parameter entries are as follows. The tag name may be followed by parameters, separated by spaces. The order of the tag parameters is arbitrary. Many parameters require specifying their values, but some parameters have no values or can be written without them, taking default values. If a parameter requires a value, it is indicated after the parameter name using an equal sign. The parameter value can be written in quotes or without them. The only case in which you cannot do without quotes is when there are spaces in the parameter value. In parameter values (as opposed to tag names and parameters themselves), case is sometimes important. Here's an example of a tag entry with parameters:
Parameter |
Purpose |
ALINK |
|
BACKGROUND |
Points to the URL of the image that is used as the background |
BOTTOMARGIN |
Sets the border of the document's bottom margin in pixels. |
BGCOLOR |
Specifies the background color of the document |
BGPROPERTIES |
When set to FIXED, the background image does not scroll |
LEFTMARGIN |
Sets the left margin of the document in pixels. |
LINK |
Specifies the color of a link that has not yet been viewed |
RIGHTMARGIN |
Sets the border of the document's right margin in pixels. |
SCROLL |
Sets the presence or absence of scroll bars in the browser window |
TEXT |
Defines the text color |
TOPMARGIN |
Sets the border of the document's top margin in pixels. |
VLINK |
Specifies the color of an already viewed link |
The use of the BACKGROUND and BGCOLOR parameters, which determine the background of the document, is discussed in detail in.
The BGPROPERTIES parameter, which accepts a single value of FIXED, is supported only by Microsoft Internet Explorer.
The BOTTOMMARGIN, LEFTMARGIN, RIGHTMARGIN, and TOPMARGIN parameters, which specify the distance in pixels between the edges of the text and the corresponding window edges, as well as the SCROLL parameter, are recognized only by Microsoft Internet Explorer, starting with version 4.0.
The ALINK, LINK, TEXT, and VLINK parameters determine the colors of links and document text.
In HTML, colors are defined by hexadecimal numbers. The color system is based on three primary colors - red, green and blue - and is designated RGB. Each color is given a hexadecimal value ranging from 00 to FF, which corresponds to a range of 0-255 in decimal. These values are then combined into a single number, preceded by a # symbol. For example, the number #800080 represents the color purple. In order not to remember sets of numbers, you can use the names of colors instead, which are given in Appendix P2. Early versions of browsers only recognized the names of 16 standard colors, marked with asterisks in the application. Modern versions of browsers recognize all 140 color names.
Text formatting
This section will look at the possibilities of formatting individual characters in the text of a document.
Block level tags and sequential tags
Some HTML tags that may appear in the BODY section are called block level tags, while others are called inline tags or, otherwise known as text level tags, although this division of tags the levels are to a certain extent arbitrary.
The difference between the levels of HTML tags is that block level tags can contain sequential tags and other block-level tags, while sequential tags contain only data and other sequential tags. Block tags describe larger document structures than sequential tags.
By default, these types of tags are placed differently in the description text: block-level tags start on a new line, while sequential tags do not.
Logical and physical formatting
To format the text of HTML documents, a whole group of tags is provided, which can be divided into logical and physical formatting tags.
Logical formatting tags denote (by their names) the structural types of their text fragments, such as program code (tag), quote (tag), abbreviation (tag), etc. (see descriptions of these and other similar tags in the following section). Using tags and you can, for example, mark individual fragments as highlighted or highly highlighted. Note that we are talking about structural markup, which does not affect the specific screen representation of the fragment by the browser. Therefore, such markup is called logical. Browsers display logical formatted snippets on the screen in a specific way by default. The display type has nothing to do with the fragment's structural type (i.e., the name of the logical formatting tag), but can be easily overridden.
Physical formatting tags determine the format for displaying the text fragment specified in them in the browser window (according to the preferences of the document author). For example, to display a snippet in italics, you can use the italics tag . This and other commonly used physical formatting tags are described later in the “Physical Text Formatting Tags” section of this chapter.
For a long time, there have been debates between developers of HTML documents about the advantages and disadvantages of one or another approach. With the release of the HTML 4.0 specification, this debate ended in favor of the use of logical formatting, as the principle of separating document structure from its presentation was proclaimed. Indeed, only on the basis of logical formatting can one flexibly control the presentation of a document using modern methods (based on style sheets, dynamically changing documents, etc.).
However, physical formatting can currently be used freely. The HTML 4.0 specification deprecated some physical formatting tags, but they are still supported by all browsers. Note that some logical formatting tags, designed to replace individual physical formatting tags, are not recognized by all browsers, which makes their use extremely inconvenient. An example is a logical tag, which is recommended to be used instead of a physical tag.
The tags discussed below relate to text-level tags, that is, they are designed mainly to mark small groups of characters. Some tags can also specify markup at the block level.
Logical text formatting tags
Tag
The tag marks its text as an abbreviation (ABBReviation). Although this tag is included in the HTML 4.0 specification, it is not currently supported by any browser.
Tag
Tag. Just like the tag, it is used to mark abbreviations. It is recommended to use this tag to mark so-called acronyms, i.e. spoken words consisting of abbreviations. The tag may in the future be used for non-visual display of elements, for example, in speech synthesis.
This tag is convenient to use in combination with the TITLE parameter, as the value of which you can specify the full form of the abbreviation. Then visual browsers, when you hover the cursor over text marked with the tag, will display the full name in the form of a tooltip.
Note that the tag is recognized only by the Microsoft Internet Explorer browser. Example:
SPbGITMO - one of the leading technical universities in St. Petersburg
Tag
The tag is used to mark quotes or titles of books and articles, links to other sources, etc. Browsers usually display such text in italics. Example:
Nevskoe Vremya is one of the most popular city newspapers in St. Petersburg
Tag
A tag marks its text as a small piece of program code. Typically displayed in monospace font. This tag should not be confused with the Block-level element tag, which should be used to mark large chunks (listings) of code.
For example:
An example of the simplest operator in the C programming language:
puts("Hello, World!");
There is another difference in the use of tags and In program code, the presence of several consecutive spaces is often important. Their display will only be saved when using the tag.
Tag
The tag marks its text as deleted. This element is useful for marking changes made to a document from version to version. A tag can be used as a text-level element and as a block-level element.
The tag has two optional parameters: CITE and DATETIME. The value of the CITE parameter must be a URL to a document explaining why the fragment was removed.
The DATETIME parameter specifies the deletion date in the format: YYYY-MM-DDThh:mm:ssTZD, which specifies the year, month, day, hours, minutes and seconds of deletion, as well as the time zone (Time Zone). For example:
The latest accepted HTML markup language specification is version 3.2 4.0
Tagged text is usually displayed as strikethrough text. The HTML 4.0 specification gives preference to this tag over the physical formatting tag or the tag, which denotes strikethrough text. However, the tag
Tag
The tag marks its text fragment as a definition (DeFinitioN). For example, this tag can be used to mark a term when it appears in the text for the first time. Example:
Internet Explorer is a popular Web browser
The tag is only supported by Microsoft Internet Explorer. Displayed in italics by default.
Tag
The tag marks its text as an insertion (INSertion). This element is useful for marking changes made to a document from version to version. A tag can be used as a text-level element and as a block-level element.
The tag has two optional parameters: CITE and DATETIME. The value of the CITE parameter must be a URL to a document explaining the details of the additions made.
The DATETIME parameter specifies the date of insertion in the format: YYYY-MM-DDThh:mm:ssTZD, which specifies the year, month, day, hour, minutes and seconds of insertion, as well as the time zone (Time Zone).
Text tagged with is usually displayed as underlined text. The tag is currently only recognized by Microsoft Internet Explorer.
Tag
Tag (EMphasis - highlighting, underlining) is used to highlight important text fragments. Browsers typically display this text in italics. Example:
Example of highlighting individual words of text
.
Tag
The tag marks text as being entered by the user from the keyboard. Typically displayed in monospace font, for example:
To launch a text editor, type: notepad
The use of this tag is preferable to the use of the physical formatting tag.
Tag
The tag marks short quotes in a line of text. Unlike a block-level tag, the display does not separate marked-up text with blank lines. Typically displayed in italics. The tag (unlike ) is currently only recognized by Microsoft Internet Explorer.
The tag has a CITE parameter, the value of which can be the source of the quote.
Tag
The tag marks the text as a sample (SAMPle). A common use of this tag is to mark text output from programs (sample output). It is also used to highlight multiple characters in a monospace font.
The use of this tag is preferable to the use of the physical formatting tag. For example:
As a result of the program's operation, the following will be printed: Hello, World! .
Tag
The tag is usually used to highlight important text fragments. Browsers typically display this text in bold font. Example:
St. Petersburg is located at the easternmost tip of the Gulf of Finland at the mouth of the Neva River< /STRONG>
The use of this tag is preferable to the use of the physical formatting tag. The tag usually marks more important fragments of text than those marked with the tag.
Tag
The tag marks the names of program variables. Typically this text is displayed in italics. Example:
Set the value of variable N
A display of some of the examples given in describing logical text formatting tags is shown in Figure. 1.1. The figure shows how when you hover the mouse over text marked with the tag, a tooltip is displayed.
Rice. 1.1. Text formatting examples
You've probably noticed that some elements give the same result. Moreover, some elements may not change the presentation of a piece of text on the screen in any way. A legitimate question may arise: why was such a variety of formatting elements created?
The answer is in the name of this group of elements. They are designed to place logical emphasis, highlight logical parts and emphasize the essence of statements. Their use is very relevant, since, probably, in the near future the capabilities of browsers will increase, for example, it will become possible to search for citations on the Web, and maybe the next generation of browsers will learn to read documents aloud. In addition, nothing prevents document authors today, using style sheets, from setting the desired display for any of the tags, overriding the default values.
Physical text formatting tags
Here is a description of physical formatting tags. Some of them are not recommended for use by the HTML 4.0 specification for the reasons given above. Some tags have been deprecated by the HTML 4.0 specification, but they continue to be supported by browsers.
Tag
The tag displays text in bold font. In most cases, it is recommended to use a logical formatting tag instead of a tag. For example:
This is a bold font.
Rice. 1.2. Examples of physical text formatting (Netscape browser)
Tag
Tag displays text in italics. For most cases, it is recommended to use the , , or tags instead of this tag, since the latter better reflect the purpose of the selected text. For example:
Selection italics
Tag
The tag displays text in a monospace font. For most cases, it is better to use the , or tags instead of this tag. Example:
This is a monospace font.
Tag
Tag displays text underlined. Canceled tag. It is recommended to use or tags instead. For example:
Example underscores text
Tags and
Tags display text with a horizontal line through it. Canceled tag. The tag should be used instead. For example:
Example of strikethrough text.
Currently, the tag is not supported by all browsers, so for now it is recommended to use it in combination with the tag. Namely, you can put a couple of tags inside a container tag
... .
Tag
The tag displays text in a font larger (than the untagged part of the text) size. Instead of this element, it is better to use heading tags, for example,
Larger font size.
Tag
The tag displays text in a smaller font size. Since there is no tag in HTML that is opposite in effect to the tag, the tag can be used for these purposes. Most browsers support nested tags, but this approach is not recommended. For example:
Smaller font size.
Tag
The tag moves text below the line level and displays it (if possible) in a smaller font size. Convenient to use for mathematical indices. For example:
Example font for subscript.
Tag
The tag moves the text above the line level and displays it (if possible) in a smaller font size. Convenient to use for assigning powers of numbers in mathematics. For example:
Example font for superscript.
Tag
The tag displays blinking text. This tag is not part of the HTML specification and is only supported by the Netscape browser. Experienced developers rarely resort to using this tag, since the presence of blinking characters on the page annoys many users.
Tag
A container tag is analogous to a block level tag. Can be used when you need to mark a piece of text to set its properties, and cannot use any other structural formatting tag.
The Microsoft Internet Explorer browser additionally allows the use of the following tag parameters: DIR, DATAFLD, DATAFORMATAS, DATASRC. A description of the parameters can be found in the second part of the book.
Rice. 1.3. Using nested text formatting tags
Formatting tags can be nested inside each other. In this case, you need to carefully ensure that one container is located entirely in another container. In Fig. Figure 1.3 shows an example of nesting an italic element within a bold element. The following HTML code fragment is used:
This is a bold font.
This italics.
And here is the text bold and italic
Tag
The tag specifies the font parameters. It refers to text-level physical formatting tags.
Assigning font parameters directly in the document text violates the basic idea of separating the content of the document and describing the form of presentation of the document. Therefore, in the HTML 4.0 specification this tag, as well as the tag, are classified as deprecated. Their further use is not recommended.
Despite these dire warnings, it appears that physical formatting can be considered acceptable for the simplest documents. In addition, the easiest way to start learning the basics of formatting is with the rules for directly specifying element formats. A novice developer still has to grow up to style design.
A tag refers to sequential elements and therefore cannot include block level elements, e.g.
Or
Text inside a table cell |
Text after table
The example above overrides the default font size twice. Initially it is 3 (default). Then it is set to 2, then 4. Pay attention to the display of this example (Fig. 1.7). It can be seen that the tag assignment does not work for tables. This is typical for many browsers, although it formally violates the idea of using the tag.
Rice. 1.7. Displaying example WITH TAG (Netscape browser)
Formatting an HTML Document
Dividing into paragraphs
Any text, be it a school essay, a note in a newspaper or a technical description of a device, has a certain structure. The elements of such a structure are headings, subheadings, tables, paragraphs, etc.
One of the first rules for drawing up almost any document is to divide its text into separate paragraphs that express a complete thought. HTML documents are no exception to this rule. When creating documents using text editors, breaking into paragraphs is done by entering a newline character. Most editors implement this when you press the key. In HTML documents, newlines do not create a new paragraph.
HTML assumes that the author of the document knows nothing about the reader's computer. The reader has the right to set any window size and use any of the fonts available to him. This means that where the line hyphen occurs is determined solely by the viewer and the end user's settings. Because line feeds in the original document are ignored, text that looks great in the document's author's editor window may turn into solid, unreadable text in the viewer window.
You can avoid this trouble by using a special paragraph division tag.
Before the beginning of each paragraph of text you should place a tag
Closing tag
not required. Browsers usually separate paragraphs with a blank line.Note
Browsers typically interpret multiple paragraph tags in a row
As one. The same applies to the line feed tag
. Therefore, it is not possible to create multiple empty lines using these tags.
Tag
Can be specified with the horizontal alignment parameter ALIGN. Possible parameter values are given in table. 1.4. The default is left alignment.
Table 1.4. ALIGN parameter values
ALIGN parameter value |
Action |
LEFT |
Align text to the left edge of the browser window |
CENTER |
Align to the center of the browser window |
RIGHT |
Align to the right edge of the browser window |
JUSTIFY |
Justification (on both sides) |
Note that justification (ALIGN = JUSTIFY) has not been supported by browsers for a long time. Many HTML language descriptions specify only three options for alignment parameter values (LEFT, CENTER, and RIGHT). Currently, all popular browsers can perform width alignment. Some problems with creating justified documents are also discussed in Chapter 8.
Note
The lack of justification currently seems surprising. This mode is used very often for printed publications. It is enough to pick up any newspaper or look closely at the paragraphs of this book - they are all aligned in width. However, until recently, justification was not allowed for HTML documents. Just a couple of years ago, no browser had such a mode. Thus, readers who are still using the Netscape browser version 3.x will not be able to see straight lines in the document. You can try to predict what other capabilities browsers will have in the future by comparing the capabilities of powerful text editors and modern browsers. An example of features that have not yet been implemented would be automatic hyphenation, etc.
Line translation
When displaying text documents in a browser, the location of line breaks within a paragraph is determined automatically depending on the size of the fonts and the size of the viewing window. Line breaks can only be carried out using word separator characters (for example, spaces). Sometimes in documents you need to set a forced line feed, which is implemented regardless of the browser settings. This is done using the forced line feed tag.
, which does not have a corresponding closing tag. Enabling a tag
into the document text will ensure that subsequent text is placed at the beginning of a new line. For example, this approach can be used to create list-type structures without using special list markup tags. Or, for example, this tag cannot be used to display poems, etc.
Here is an example of using forced line feed (Fig. 1.8):
Using forced line feed
Over darkened Petrograd
November breathed the autumn chill.
Splashing with a noisy wave
To the edges of your slender fence,
Neva was tossing around like a sick person
Restless in my bed.
A.S. Pushkin. Bronze Horseman
Rice. 1.8. Tag
can be used to force a line feed
Unlike the paragraph tag
When using the tag
an empty string will not be generated.
Using a tag
requires caution - it is possible that the browser has already made a line break one or two words before it encountered your tag
. This happens if the reader's viewer window width is smaller than the same setting of the program with which you tested your document. In this case, it may turn out that only one word remains on a line in the middle of a paragraph, thereby ruining the beauty of the document layout.
Note
When using the tag
To break text around an image or table, you can set the CLEAR parameter to stop text wrapping. You can read about this in chapters 3 and 4.
Tags u
There are situations when you need to perform the opposite operation - disable line feed. There is a container tag for this. Text marked with this tag is guaranteed to be on one line, regardless of its length. If the resulting line extends beyond the browser's viewing window, a horizontal scroll bar will appear.
Note
To ensure the continuity of text located in table cells, there is a special parameter of the NOWRAP tag
By marking up text using the non-breaking line tag, you can get very long lines. To avoid this, you can indicate to the reader's browser the location of a possible line feed, which will be performed only when necessary (the so-called "soft" line feed). This can be done by placing a tag (Word BReak) in the right place in the text, which is the same as the tag
, does not need a closing tag.
Note
The tag is not supported at all by the Netscape browser. The Microsoft Internet Explorer browser recognizes this tag only in text marked with tags.
Headings inside an HTML document
Along with the title of the entire document, a Web page can use headings for individual parts of the document. These headings can have six different levels (sizes) and are pieces of text that stand out on the screen when the browser displays the page.
The tags , , , , and are used to mark up headings. These tags require a corresponding closing tag. Heading number 1 is the largest (top-level heading), and heading number 6 is the smallest. Heading tags are block-level elements, so they cannot be used to mark up individual words of text to increase their size. Heading tags insert a blank line before and after the heading, so no paragraph or line break tags are needed.
Heading tags can be specified with the horizontal alignment parameter ALIGN. Possible values of the parameter are the same as the alignment parameters of the paragraph tag
(see table 1.4).
An example of using headings of different levels with different alignment (Fig. 1.9):
Heading examples
Heading size 1
Heading size 2
Heading size 3
Heading size 4
Heading size 5
Heading size 6
Body of the document
Rice. 1.9. Display headings in different sizes
Horizontal lines
Another method of dividing a document into parts is to draw horizontal lines. They visually emphasize the completeness of a particular area of the page. Nowadays, a raised, pressed line is often used to indicate the “volubility” of a document.
The tag allows you to draw a raised horizontal line in the window of most viewing programs. This tag is not a container, so it does not require a closing tag. A blank line is automatically inserted before and after the line. Tag parameters are presented in table. 1.5.
Table 1.5. Tag options
Example:
This example sets a horizontal line that takes up half the width of the viewport and is positioned in the middle of the window. Note that the alignment options only make sense when the line does not occupy the entire width of the window.
Note
The Netscape browser does not allow the COLOR tag parameter.
Using preformatted text
As you can see in the sections above, special tags should be used to break up text into paragraphs and force a line break. However, there are times when it is necessary to include text in an HTML document that already has formatting done in the traditional way using newlines, the required number of spaces, tab characters, etc. To solve such problems, a special container tag is provided Defining pre-formatted ( n reformatted) text.
The text marked with the tag will be displayed as it looks in a regular text editor. A monospaced font will always be used for display. This will give you more control over the document viewer's output, although at the cost of some loss of flexibility.
One of the options for using this tag is tables built without using special table markup tags. Other important
The application is to display large blocks of program code (Java, C++, etc.) on the screen, preventing the browser from reformatting them.
Text inside a container Can contain text-level formatting except the following: , , , , , , , , . It is not acceptable to include block-level formatting elements, such as heading tags, within preformatted text. The paragraph tag, logically, should also not occur inside preformatted text, but if it does, it will implement a new line transition (without creating an empty one).
Note
The tag has an optional WIDTH parameter, the purpose of which is to tell the browser the maximum length of a line of preformatted text. Depending on this value, the browser could select the desired font and/or indentation to optimally display the preformatted text. The default value has been suggested to be 80. Other recommended values are 40 and 132. Note that for readers with significant computing experience, these numbers speak volumes. In fact, modern browsers ignore the WIDTH parameter.
There are several more tags that solve a similar problem. These include the , AND tags. All three of these tags are marked as deprecated in the HTML 4.0 specification. This means that browsers will no longer support them in future versions. It is recommended to use the tag instead of these tags.
Tag
A container tag is a block-level element that serves to highlight a fragment of a document. The purpose of this selection is to control the parameters of this fragment, which is usually done by assigning styles. Here's an example:
(Document fragment)
In this example, a fragment of an HTML document is framed with tags to set some of its properties. In this case, all text elements of the selected fragment will be displayed in green. An analogue of a text level tag is the element.
Note that it is not advisable to use direct assignment of style properties of a separate fragment, as is done in the example, in accordance with the concept of separating the structure of the document and its presentation. You should use style sheets, which will be discussed in the second part of the book.
Tag
The container tag is designed to horizontally align all elements in the middle of the browser viewport. It is block level and is useful for centering elements such as tables, since they cannot be centered by assignment
ALIGN=CENTER tag