Rules for constructing HTML documents. Nested rules Rules html general rules fantasy

The article is not entirely relevant
In 10.2 and higher, the ability to rename the page with site rules directly in the engine admin panel was added, when directly editing the text of the rules. However, the page with the site rules remains. It exists and is located on any DLE website at http://my_site/rules.html
How to squeeze all the juice out of this address - read on

Page with site rules in CMS DLE

The site rules page is a system static page. It is processed by the engine and generated in the same way as a regular static page. It’s just impossible to remove it - it’s not provided for by the engine developer. Even if the site rules themselves are disabled for display during registration, then the page with the site rules is always available at http://my_site/rules.html The first search engine that finds it there will start vomiting and spitting on the text and title. It’s no wonder. After all, on all DLE sites it’s the same thing.

When a page with site rules ends up in the site map, it is regarded by the search engine as “junk” and is not included in the search index, since the site rules are the same almost everywhere. Therefore, the page with site rules in DLE, by default, is prohibited (closed) from search indexing in the file ( line Disallow: /rules.html).

The uniqueness of the “Site Rules”

My personal opinion about the page with the site rules and its uniqueness is that it is an atavism that distracts the user’s attention during registration. The rules of the site are a rudimentary outgrowth, the uselessness of which has been successfully proven by the organizers of social networks.

No, well, has anyone seen any formidable or special rules when registering on Facebook or Twitter? Or maybe they are on VKontakte and Odnoklassniki? Same thing!

And some website, with a visitor of 1000 uniques -
begins to write its own unique rules for users.
As for me, the best rules on the site are their complete absence.
If the user is normal and adequate, he already understands everything.

No page - no problem

It's no secret that blocking pages and directories from search indexing is not a panacea. One way or another, any page of the site will sooner or later be “chewed” by the search engine. For example, take the same Yandex. Its search robots will pump out absolutely everything they can find from the site and only then will they begin to sort and think about whether to return pages to search or not. This is quite obvious, despite Yandex’s touching assurances that it and its robots do not download unnecessary material from the site. Like, if a web page is closed from indexing, then Yandex saves only its address with the mark , or(who will close it how).

Instead of poking around and blocking a “junk” page with site rules from search indexing, it is much better to remake it into some other useful thing and open access to it for search engines - let them calm down. Or, at least just write your behavior on the site and, again, allow search engines to access the page.

Opening site rules for search engines

We take a bold step and give search engines access to the site rules page. To do this, in our file we find the line Disallow: /rules.html and delete it nafik. It is done! Now, any search robot will be able to officially get into the open “Site Rules” and, of course, say “Fe-e!” and “Be-e!” To prevent this from happening, we rework the “Site Rules” page - insert our own unique text on any topic, pictures and change the name (title) of the page.

Editing the “Site Rules” page

Editing the page with site rules is available in the admin panel of the DLE engine, in the “List of all sections” - “Rules on the site” section. Editing the “Site Rules” page is performed as for any other static page - in the normal operating mode of a visual text editor. Here the only problems can be with writing unique text and selecting unique pictures. A little higher, there is a special window for entering the title (title) for the page being updated. But, such an innovation appeared in, starting with version 10.2.

To rename the site rules page
in older engine models -
will need to delve into it system files.

Renaming the “Site Rules” page
(for CMS DLE 10.1 and lower)

Directly renaming the “Site Rules” page itself is done in the adminpanel.lng file, which is located in the language/Russian/adminpanel.lng folder. The adminpanel.lng file is a system file of the DLE engine. To edit it, go to your server (otherwise there is no way).

Open the file adminpanel.lng.
Looking for a string
"rules_edit" => " General rules Online"
We change the words “General rules on the site” to our new name. Let's close. Save. (You can only change the Cyrillic alphabet, which is between the quotes. Otherwise, it will stop working altogether.)

Clear the engine and browser cache. After editing and saving the adminlogs.lng file, you must clear the engine cache and browser cache in order to force the engine to generate a new page with a new name, and the browser to download it. If this does not help and the old name continues to be displayed, you need to go to the admin panel of the engine, edit and resave the “Site Rules” page with some minor sign. For example, put a period in the text (then you can correct everything back). Such bullying and atrocities will definitely clear the brains of the engine and server and force them to generate and display a new name.

Thinking out loud. It feels like dear celsoft is reading this blog. A little later, after this publication, in the admin panel of the engine version of CMS DLE 10.2 it became possible to rename the page with site rules in a normal civilized way, without tedious poking around in the system script files. Many thanks to the developers of CMS DLE for their work and attention to the problems of ordinary people.

What is HTML

The World Wide Web (WWW) is made up of Web pages that are created using the so-called HyperText Markup Language (HTML). Although many people talk about programming in this language, HTML is not a programming language in the traditional sense. HTML is a document markup language. When developing an HTML document, you mark up a text document in the same way that an editor does it with a red pencil. These marks serve to indicate the form in which the information contained in the document is presented.

Special HTML document viewers, often called browsers, are used to interpret files marked up according to the rules of the HTML language, format them as Web pages, and display their contents on the user's computer screen. Exists a large number of browser programs developed by various companies, however, today, from the entire variety of programs, two leading programs clearly stand out - Netscape Communicator and Microsoft Internet Explorer.

Netscape Navigator is developed by Netscape Communications Corporation. Like many software products, there are a number of versions of this program. The latest version of Netscape Communicator at the time of writing was version 4.7. Internet Explorer is developed by Microsoft. Latest version this program is 5.0.

Other browsers lag far behind in popularity. Several years ago, Netscape's browser occupied a leading place among browsers, with more than two-thirds of users using this particular browser. With the release of its browser, Microsoft made a huge effort to conquer this part of the market. Often in the media

There have been reports of a war between browsers for users. Now these two browsers are comparable in popularity. The growing popularity of the Microsoft browser is facilitated by the inclusion of the browser in the operating system Windows systems 98, however, ultimately the choice of browser is up to the user.

Modern browsers have extensive capabilities, but the main thing for them is the interpretation of documents marked up according to HTML rules. This book is mainly devoted to the description of these rules. In the first part we will look only at the fundamental principles of constructing HTML documents.

To understand what markup language is, let's remember the good old days when many people worked with text editors like WordStar. In them, to highlight a phrase, for example, in bold, special marks were placed at its beginning and end (/B and /b):

/B This text will be displayed in bold/b

When outputting such text to a printing device (we are not talking about displays yet, in those distant times they either did not exist at all or there were alphanumeric displays that did not allow changing fonts), the symbols / in were forced to use bold font until the characters /b will be encountered.

HTML works exactly the same. If there is a need to highlight text on the screen in bold, then this can be done in a similar way:

This text will appear in bold font

Symbols turn bold on, and symbols turn it off. In HTML, such characters that control the display of text and are not themselves displayed on the screen are called tags (from the English word tag - label, sign).

All HTML language tags are separated by delimiter characters (< и >), 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 , the corresponding closing tag You can always omit it. The end of data for a table cell will be recognized by the appearance of the next tag or table line ending tag.

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

  • or paragraph 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. The general rules for writing parameters 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:

    Here for the tag

    two parameters are specified. The first BORDER parameter is specified without a value. The second ALIGN parameter is left.

    The subsequent chapters of the first part of the book will describe the purpose of HTML language tags and their parameters. In general, tags can have different parameters, but there are a number of parameters that are common to almost all tags. We will mention here the general parameters of tags so as not to talk about them further when describing each tag.

    All tags that can be used in a section of an HTML document can have the parameters CLASS, ID, LANG, LANGUAGE, STYLE and TITLE. The use of these parameters is useful, first of all, when styling documents, which will be discussed in the second part of the book.

    The CLASS, ID, STYLE parameters are supported by Internet Explorer starting from version 3.0, and Netscape starting from version 4.0. These parameters are needed when using styles.

    Parameters LANG, LANGUAGE, TITLE are supported only by Internet Explorer starting from version 4.0. These parameters indicate, respectively, the language used (for example, for Russia: LANG=ru), the language for writing scripts (for example, LANGUAGE=JavaScript), as well as the text of the tooltip displayed when the mouse pointer hovers over this element (TITLE).

    In modern HTML, in addition to language tags and their content, scripting codes (javascript or VBScript) are also written in the HTML source code. In the first part of the book this is hardly mentioned anywhere, but the second part is entirely devoted to the use of scripts.

    Concluding the general overview of HTML, we note that the simplest HTML documents are ordinary text files, to view and edit which you can use any text editor. These files usually have the extension HTM or HTML.

    HTML Specifications

    The HTML language gained popularity in the mid-90s due to the exponential growth of the Internet. By this time, there was a need to standardize the language, since various companies, who developed software for Internet access, offered their

    variants of HTML instructions, the number of which kept growing and growing. The time has come to come to some kind of unified agreement regarding the use of HTML language tags.

    The work of creating the HTML specification was undertaken by an organization called the World Wide Web Consortium (abbreviated as W3C). Her task was to compile a specification that reflected the current level of development of language capabilities, taking into account the various proposals of browser development companies. Thus, in November 1995, the HTML 2.0 specification appeared, designed to formalize the practice of using HTML that had developed by the end of 1994.

    The approval scheme for specifications is as follows. The W3C consortium releases a draft specification, after discussion of which it releases a so-called draft version of the specification and offers it for discussion for a certain period. After a period of discussion, the working version of the specification may become a recommendation, i.e., an officially accepted version of the HTML specification.

    Shortly after the 2.0 specification, a working version of the 3.0 specification was released, which expired in September 1995. This specification was never adopted as a formal recommendation. It was planned to include a wide variety of tags and capabilities specific to individual browsers, however, the W3C Consortium has not found a way to develop a good specification for such a large number of instructions.

    After much deliberation, HTML 3.2 was released in May 1996. The project was based on some of the tags available in version 3.0, which showed stability in operation. After several months of discussion, version 3.2 became a proposed specification in September 1996 and a formal recommendation in January 1997.

    July 1997 saw the release of the proposed HTML 4.0 specification, which became an official recommendation in December 1997. This is the latest accepted specification to date.

    In the following brief overview history of the development of the HTML language is hardly worth describing in detail the features of various specifications, especially since in real life developers do not always follow the recommendations of the Consortium. Let us note just some of the ideas underlying the latest specification.

    The key idea in the HTML 4.0 specification was to separate the description of the structure of the document from the description of its presentation on the monitor screen. Experience has shown that separating document structure and presentation reduces the cost of supporting a wide range of platforms, environments, etc., and also makes document revisions easier. In accordance with this idea, methods for describing representations should be used more widely.

    document using style sheets, rather than specifying specific presentation data interspersed with the content of the document. To implement this idea in the HTML 4.0 specification, a number of tags used to directly specify the form of presentation of HTML elements have been canceled. Tags canceled for this reason include , , , , , . Among other canceled tags, we note , , , . Instead of canceled tags, they are offered alternative options implementation of appropriate opportunities, which we pay special attention to in this book.

    The concept of a deprecate tag is as follows. If a tag is deprecated in this language specification, it means that browsers should continue to support such tags for now, but their use is not recommended. In future specifications, these tags may be made obsolete. Obsolete tags may no longer be supported by browsers. In the HTML 4.0 specification, only three tags are deprecated: , AND . Information about which tags are included in the specification can be obtained from the table given in Appendix A1.

    Official information about the HTML specification can always be obtained from the W3C Web site at http://www.w3.org/TR/. Specification 4.0 is located at http://www.w3.org/TR/REC-htmI40-971218.

    Note that, logically, the official specification should play the role of a guiding and guiding force, ensuring that information is presented in the same way across different browsers. This is the ideal option to strive for. In reality, things are not so good. New ideas are constantly emerging, implemented by development companies in their browsers and promoted by them. Successful ideas take root and are then picked up by other developers. Some of the opportunities remain specific features separate browser. Successful designs eventually end up in the specification and become generally accepted. Thus, the process of improving browser capabilities and clarifying the specification is ongoing, influencing each other.

    Document structure

    The first tag to begin describing HTML documents is the . It should always begin the document description, and the document description should end with the tag. These tags indicate that the lines between them represent a single HTML document. The document itself is an ordinary ASCII text file. Without these tags, a browser or other viewer may not be able to identify the document format and interpret it correctly.

    Most often, the tag is used without parameters. IN previous versions the VERSION parameter was used, deprecated by the HTML 4.0 specification. This parameter has been replaced by the tag.

    Majority modern browsers can recognize a document that does not contain tags and yet their use is highly desirable.

    The document itself is located between a pair of tags. A document can consist of two sections - a header section (beginning with the tag ) and a content section of the document (beginning with the tag ). For documents describing frame structures, the FRAMESET section (with the tag) is used instead of the BODY section. Next, we will consider the rules for compiling the HEAD and BODY sections of the document. The construction of documents containing frames is discussed in Chapter 5.

    HEAD document section

    The HEAD section of a document defines its title and is not a required tag, but a well-written title can be quite useful. The purpose of the header is to provide necessary information to the program interpreting the document. Tags located inside the HEAD section (except for the title of the document described by the tag) are not displayed on the screen.

    The header section opens with the tag . Typically this tag comes immediately after the . The closing tag indicates the end of this section. Between the mentioned tags are the remaining tags of the header section.

    Document's name

    The container tag is the only required head tag and serves to give the document a title. It is usually shown in the title bar of the browser window. The tag should not be confused with the document file name; on the contrary, it represents text string, completely independent of the file name and location, which makes it quite useful. The file name is strictly defined operating system the computer on which it is stored. You should also distinguish the title of the document (with the tag) from headings within the document, usually marked with tags.

    Note

    The mandatory title of the document, generally speaking, has the character of a strong recommendation. A document without a tag will also be displayed by browsers. Wherein various browsers The window title will display various information. So early versions Netscape browser displayed the line "No title". Other browsers either show nothing or display the address of the downloaded file, repeating the information in the browser's Location panel.

    The title of the document is written between the tags and and is a line of text. In principle, the name can be of unlimited length and contain any characters except some reserved ones. In practice, you should limit yourself to one line, keeping in mind that the name appears in the title bar of the browser window. You should also remember what will remain of the document title when minimizing the browser window. It is recommended to limit the length of the document title to 60 characters. You can see how the title is displayed in the browser window in any picture in this book, which gives an example of how a document is displayed.

    By default, the text contained in the document title is used when creating a bookmark for the document. Therefore, for greater information content, avoid faceless names (Home Page, Index, etc.). Such words used as bookmark names are usually completely useless. The title of the document should briefly describe its content. Note that when displaying documents with a frame structure on the screen, when a separate document with its own name is loaded into each frame, only the name of the main document will be visible on the screen. However, set the name individual documents, designed to be loaded into frames, is also highly recommended. This issue is discussed in more detail in Chapter 5.

    The importance of the document title is determined by the following fact. Since the tag is located almost at the very beginning of the HTML file, once the document starts loading, it is the first thing that is displayed. Next, the main content of the document is loaded, and the browser begins formatting the document in the window. This process, generally speaking, depending on the content and structure of the document, as well as the connection speed, can take a long time. For quite a long time, the user will contemplate a blank screen, the only informative line of which will be the title of the document. Quite often (if the connection is lost or if the user does not want to wait for the document to finish loading), all information about the document ends there.

    Relationship with other documents

    Often HTML documents are interconnected, that is, they have links to each other. Links can be either absolute or relative. Both of them have disadvantages. Absolute links can be too cumbersome and stop working if a lower document in the hierarchy is moved. Relative links are easier to enter and update, but this link is also broken if the document that is higher in the hierarchy is moved. Both types of connections can be broken when transferring a document from one computer to another.

    It often happens that a user has downloaded a large document onto his machine and disconnected from the network to study it in detail. All links in the local copy of the document will stop working. To “reanimate” them, you will have to return to the original document located on the remote computer.

    Fortunately, the HTML developers anticipated this problem and added two tags, and , that are included in the header to ensure that the connection between documents is not broken.

    Tag

    The tag is used to indicate the full base URL of the document. With its help, a relative link continues to work if the document is moved to another directory or even to another computer. The tag works similarly to the MS-DOS path command, which allows the viewer to determine the link to the document you are looking for, even if it is in a document that is higher in the hierarchy, located on another computer.

    The tag has one required HREF parameter, followed by the full URL of the document. Below is an example of using the tag.

    Specifying a base address

    The tag tells the browser where to look for the file. If the user is working with a local copy of the file and his machine is not disconnected from the network, the News icon image will be found and shown in the browser window.

    Tag

    Even if the tag allows you to find the file, the question of the relationship between the documents remains open. The importance of these relationships increases as the complexity of your documents increases. In order to maintain a logical connection between them, the tag is introduced into HTML.

    A tag indicates a relationship between the document containing the tag and another document or object. It consists of a URL and parameters that specify document relationships. The document title can contain any number of tags. Table 1.1 describes the tag parameters and their functions.

    Table 1.1. Tag options

    Here are examples of a tag with parameters:

    The first line indicates a link to the document's table of contents file (toc.html - table of contents) with a direct contents relationship. The second line describes the relationship to the document's author URL (with the reverse made relationship).

    Many different relationships can exist between documents. Examples of other REL parameter values: bookmark, copyright, glossary, help, home, index, toc, next, previous. The REV parameter can also take the following values: author, editor, publisher, owner.

    Tag

    The development of new hypertext markup language specifications takes a long time, and during this time, browser companies manage to release several versions of their products. Therefore, another tag can be added to the head section to allow document authors to identify non-HTML information.

    This information is used by the browser for actions that are not covered by the current HTML specification. You won't need the tag to create your first HTML documents, but you'll likely need it as your pages become more complex.

    Example:

    The Netscape Navigator and Internet Explorer browsers will interpret this entry as an instruction to wait 60 seconds and then load a new document. This instruction is often used when changing the location of documents. A small document with the given line can be left at the document's old location to automatically link to its new location.

    Next line:

    instructs the browser to reload the page every 60 seconds. This can be useful if the data on the page is updated frequently, such as when tracking stock prices.

    The use of the element to solve some typical problems has become very popular. An example would be specifying keywords used by search engines. This method allows you to include additional words in the document index that may not be explicitly included in its content. To do this, the name of a certain property is specified in the tag as the value of the NAME parameter. And using the CONTENT parameter, the value of this property is specified, for example:

    The HTML specification does not define any specific names for the properties written in the . However, there are several commonly used properties, for example, description, keywords, author, robots, etc.:

    The given tags could well be indicated, for example, for the electronic version of this book.

    The tag can have the parameters specified in the table. 1.2.

    Table 1.2. Tag options

    Another important purpose of the tag is to indicate the text encoding. So, for text in Russian in Windows encoding, you need to write the following line:

    Other header elements

    There may be two more tags in the document header section - and . Their purpose is related to the use of style sheets in a document and writing scripts. These issues are discussed in detail in the second part of the book.

    Document section BODY

    This section of the document contains its content. Most of the tags discussed later in this chapter and subsequent ones should be located in this section of the document. Here we will consider only some general issues.

    The BODY section of the document must begin with the tag and end with the tag, between which the entire content of this section is located. Strictly speaking, the presence of these tags is not required, since browsers can determine the beginning of the content of the document based on the context. However, their use is recommended.

    The tag has a number of parameters, none of which are required. The list of parameters is given in table. 1.3.

    Table 1.3. List of tag parameters

    Parameter

    Purpose

    ALINK

    BACKGROUND

    Points to the URL of the image that is used as the background

    BOTTOMMARGIN

    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

    Defines 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 as 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 the 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 canceled. 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.

    The tag refers to sequential elements and therefore cannot include block level elements, e.g.

    Or

    .

    The following parameters can be set for a tag: FACE, SIZE and COLOR. Note that the Netscape browser also allows the use of two additional parameters: POINT-SIZE and WEIGHT, the description of which is omitted.

      FACE

      The FACE parameter is used to specify the type of font in which the user's viewer will display text (if such a font is available on the computer). The value of this parameter is the name of the font, which must exactly match the name of the font that the user has. If no such font is found, this instruction will be ignored and the default font will be used.

      You can specify one or several font names, separating them with commas. This is a very useful property, since different systems may have almost identical fonts with different names. Another important quality is to set preferences for using fonts. The font list is scanned from left to right. If the user's computer does not have the font listed first, an attempt is made to find the next font, and so on.

      Here is an example of using the FACE parameter:

      Purpose of fonts


      An example of specifying a font name.

      In Fig. Figure 1.4 shows how the Netscape browser displays an example. In the example, the Verdana font is indicated as the preferred font; if it is absent, the Arial font will be used, etc.

    Rice. 1.4. Netscape browser example display

      SIZE

      This parameter is used to specify font sizes in arbitrary units from 1 to 7. The specific font size depends on the viewer you are using. It is generally accepted that a “normal” font size corresponds to a value of 3.

    Default font size settings, as well as the amount of absolute font size change, vary between browsers. In Fig. Figure 1.5 shows the Netscape browser settings window, which sets the default fonts.

    The font size is indicated both as an absolute value (SIZE=2) and as a relative value (SIZE=+1). The latter method is often used in combination with setting the base font size using the .

    Note

    When specifying font sizes, entries like "2" and "+2" (unlike most programming languages, in which the unary "+" sign can be omitted) give fundamentally different results.

    Here's an example that uses different methods for assigning font sizes. An example display is shown in Fig. 1.6.


    Rice. 1.5. Netscape browser font settings window


    Rice. 1.6. Assigning font sizes

    Assigning font sizes

    Font size 1

    Font size 2

    Font size 3

    Font size 4

    Font size 5

    Font size 6

    Font size 7

      COLOR

      This option sets the font color, which can be specified using standard names or in the #RRGGBB format. Here is an example of a document with multi-colored text.

      Choosing a font color

      Green text

      Red text

    Tag

    The tag is used to indicate the default font size, type, and color used in the document. These values ​​are required for the entire document, but can be overridden in necessary places using the tag. After the closing tag, the tag's effect is restored. Default font settings can be overridden multiple times in a document, meaning a tag can appear any number of times in a document.

    Note

    The tag can also appear in a section of the document.

    Note that there is no closing tag for the tag.

    The parameters can be exactly the same as for the tag, namely: FACE, SIZE and COLOR. The purpose and rules for writing parameters are similar.

    Note

    The Netscape browser does not allow the FACE tag parameter.

    Let's give an example of using the tag.

    Assigning font sizes

    Text written in the default font.

    Font size 2.

    Font size 4.

    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 . You can learn more about this in Chapter 4.

    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 expense of some 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

    .

    Essentially a tag is a short form of the following entry: . Further use of the tag is also undesirable for the reasons noted in the previous section.

    Including comments in a document

    You can include comments in an HTML document that are not visible to the reader. They can consist of any number of lines and must begin with the tag. Anything contained within these tags will not be displayed on the screen when viewing the page.

    How to write correct CSS code?

    Without knowing the basics, it is impossible to move forward. Moreover, these basics must be trained to a subconscious level. You must know all the rules for writing clean, understandable code by heart and apply them everywhere. Start right with your current or, at most, your next project. This will be your CSS bible


    Below, see 15 golden rules for writing user-friendly and professional CSS code

    1) Use CSS-Reset

    CSS-reset is a certain piece of code that is written at the beginning of our style file, in which all values ​​are reset and all the basic parameters are set for all styles, which we would most likely have to write for each specific id/class. This allows you to shorten the code later, as well as avoid differences in display between browsers.

    Here is a CSS-Reset example taken from http://meyerweb.com/eric/tools/css/reset/index.html

    /* v1.0 | 20080212 */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del , dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul , li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td ( margin: 0; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; ) body ( line-height: 1; ) ol, ul ( list-style: none; ) blockquote, q ( quotes: none; ) blockquote:before, blockquote:after, q: before, q:after ( content: ""; content: none; ) /* remember to define focus styles! */:focus ( outline: 0; ) /* remember to highlight inserts somehow! */ ins ( text-decoration: none; ) del ( text-decoration: line-through; ) /* tables still need "cellspacing="0"" in the markup */ table ( border-collapse: collapse; border-spacing : 0; )

    2) Use abbreviations

    For example, to write a long

    Border-top: 5px; border-right: 10px; border-bottom: 15px; border-left: 20px;

    we can write briefly:

    Border: 5px 10px 15px 20px;

    that is, clockwise starting from the top.

    Mainly abbreviated border, margin, padding, font and background.

    You can see more details about this

    But colors can be reduced like this:

    If the color code consists of 3 repeating digits, then you can simply write down these three digits.
    For example: #FFFFFF can be written as #FFF, or #990055 can be written as #905, but #F091A4 cannot be abbreviated.

    3) Use comments

    Use comments wherever you should - they really help organize the code, making it more understandable for yourself and for those who will work with it

    It looks something like this:

    /* Your comment here */

    Comment:

    a) Title of the style page - write who the author of the code is and when it was written

    b) Mark style sections - this will organize all the code into sections.
    For example:

    /************************************************/ /* Sidebar */ /** **************************************/

    c) Comment on problem areas. For example, those where the page may have differences in different browsers. For example:

    Input /* IE6 Problem */

    d) Write small comments to those with whom you work - for example, when something needs to be improved.

    4) Add a Flower Legend

    With small css files it is not difficult to track all the colors of the site.
    But what if we have 5000 lines of code? - you can’t allow the wrong colors to be used.
    For this purpose, there is a color legend - that is, a list of the colors that we use in our file. For example:

    /* /* light blue: #4595be /* dark blue: #367595 /* red for links: #9F1212 ************************** ******/

    5) Remember what Position:realtive and Position:absolute are

    Most beginning layout designers get confused by these concepts, but there is a rule that allows you to avoid confusion.

    Position:absolute positions the object relative to the page - no matter where it is located in the HTML stream. The default value is 0 on the left and 0 on the top.

    Usually this option is not used because it is inconvenient and has limited options. But what will be useful to you is that if you set the parent (“wrapper”) of our element to Position: realtive, then Position: absolute will be aligned Relative to the upper left corner of the parent. So you can add this property as needed. Clearly in the picture:

    6) Avoid using hacks

    Sometimes browsers like IE6 and IE7 simply force us to use hacks. Khaki is an immediate error for the validator. So put it in special css files for each browser.
    You can see special entries for hacks for each browser and how to put them into separate files

    7) Use Margins in your location descriptions

    This is not something that gets noticed very often, but it helps avoid problems across different browsers.

    The idea is this: instead of using padding on the parent, we use margin on the child elements. So, instead of

    #main-content ( padding-left: 10px )

    #main-content ( ) #main-content #left-column ( margin-left: 10px )

    There is nothing wrong with using padding, but experience shows that margin is better

    8) Use floats

    If you want to assign a float to an element, then write overflow: hidden to its parent

    Ul ( overflow: hidden; ) ul li ( float: left; )

    Without this property, the element may flow unattractively; problems may also arise when setting margins or borders.

    If you want the element not to be floated, specify clear:both below the floated element. This is often used instead of overflow: hidden;

    9) Add display:inline for float elements

    A fairly well-known problem in IE6 with doubling margins on float elements. That is, if we need 20px, then we have to write 10px, because this indent doubles. Although IE6 is already dying out, and many designers do not spend time optimizing the site for it, still a small piece of code will make the display in it more pleasant. So, let's put

    Display: inline /* IE6 Problem */

    for an element that has a float applied to it

    10) Making life more comfortable with sprites

    Sprite pictures are a very convenient thing. They give an overview of the entire page's graphics and reduce loading times.

    If you know English, then here

    11) The structure of the site files should be clear

    Take the time to make the site structure clear. Put everything on the shelves.
    For example:

    Here “Website Name” is the name of the site we are working with. This folder contains the HTML files for the site, plus the assets and styles folders.
    The assets folder contains files that can be downloaded from the site, such as archives or PDF files. The styles folder contains, in turn, the css, images, javascript folders.

    • css - contains all css files such as reset.css, layout.css and main.css
    • images - all pictures of the site. This folder can also be divided into sections.
    • javascript - all javascript files.

    This diagram is approximate and can be displayed in different ways. The idea is that it helps you work faster and makes the site clearer and neater.

    12) Expand styles

    Optional advice - It is better to write the names of classes and id styles, observing a tree structure, so that everything is clear and visual.

    13) Use pixels rather than relative values

    Everything is quite simple - pixels load the code less, since the document does not have to calculate percentages of relative values.

    The problem with relative quantities is the transmission of this relativity.
    To make it clear, I will explain with an example:

    body ( font-size: 62.5% ) means font-size: 1em, that is 10px.

    If #blog-content needs 14px, write:

    #blog-content ( font-size: 1.4em; )

    Now if the H3 tag inside #blog-content needs 20px, then it could be set like this:

    #blog-content ( font-size: 1.4em; ) #blog-content h3 ( font-size: 2.0em )

    Everything would be fine, but we have relativity. And these 2.0em are applied to 1.4em
    #blog-content’a , and as a result, the size we will get is 28px.

    So use fixed values.

    14) Limit pseudo-classes to anchor tags

    New browsers do not have this problem; it all comes down to a number of older browsers, led by IE6.
    The problem is that in older browsers pseudo-classes (like :hover) only work when applied to a tag a, that is

    #header ul li:hover ( background-color: #900 )

    doesn't work in IE6

    This problem is fixed with jQuery

    15) Avoid problems with selectors

    Use selectors where possible

    For example, use instead

    #main-content.main-header

    #main-content h1

    Be careful with grouping selectors

    After all, relative values ​​can play wrong here if you use them

    If everything is ok in this example,

    Main-content div,.main-content p ( color: #000; )

    On this note, be careful with relative values.

    Main-content div,.main-content p ( line-height: 1.3em; )

    And finally

    To write successful code, avoid constantly wrapping one thing into another and so on.
    Learn h1, ul and p tags.
    The key to success is simple - practice, practice, practice

    Good luck with your training)

    » »

    Rules are part of our world and constantly guide our daily actions. In almost every area of ​​our lives there are rules - rules of behavior, rules of etiquette, rules of crossing the street - the list can be endless.

    What are the rules? It is a set of instructions that must be followed or obeyed. There are many English words that imply rules, or refer to rules:

    • Cautions - warning
    • Commandments – order, directive
    • Directions - instructions
    • Forewarnings - warning
    • Guides
    • Guidelines
    • Instructions - instructions
    • Laws - laws
    • Policies - settings
    • Procedures
    • Regulations - rules
    • Warnings - warnings

    Google shortcode

    Rules affect us every day and are hard to avoid even in the simplest of places, even when we are just walking down the street it is impossible to miss all the signs posted around us giving warnings and indicating to the rules to follow. The easiest way to explain a rule is to write it down in a book or put up signs that everyone can see. Here are some rules posted in the form of signs that we can often see on the streets and in public places, known as warning signs.

    • no cycling – you cannot ride bicycles
    • no entry – entry is prohibited
    • no skating allowed - you cannot roller skate
    • beware of oncoming bicycles - beware of oncoming bicycles
    • Keep clear = do not block this area – do not occupy this area
    • you can’t fill your gas cans here - you cannot fill gas cylinders
    • poison = do not eat it – poison = you can’t eat
    • no smoking allowed - no smoking
    • beware of people crossing the road - be careful, pedestrians
    • no parking allowed – parking is prohibited
    • do not drop litter - do not throw garbage
    • no children allowed – children are not allowed
    • no photography allowed – photography is prohibited
    • please clean up after your dog – clean up after your dog
    • danger of death – danger, high voltage electricity nearby – dangerous! – dangerous, high voltage
    • no spitting allowed - you can’t spit

    As you can see, there are a lot of rules around us, and we must follow them, although it must be said that sometimes people do not follow the rules, they break the rules, or go against the rules. the rules), sometimes they are “caught” and punished (they are punished). If you break a rule, you may be forced to pay money, i.e. a fine/penalty, or worse, may force you to go to the police station.

    Have you ever broken the rules? People who always follow the rules are called “law abiding”, and people who break the rules are called “law breakers”.

    Finally, we would like to wish you “be good!” , “follow the rules!”, “stay out of trouble!”