Coding. Reasoning about the semantics of HTML code with examples Semantically correct code

Coding. Reasoning about the semantics of HTML code with examples Semantically correct code

03.12.2021

(substitutions). In replacement ciphers, letters are changed to other letters from the same alphabet; when coding, the letters are changed to something completely different - pictures, symbols of other alphabets, sequences of different characters, etc. A table of unambiguous correspondence between the alphabet of the source text and the code symbols is compiled, and in accordance with this table, one-to-one coding occurs. To decode, you need to know the code table.

There are a large number of codes used in different areas of human life. Well-known codes are used for the most part for the convenience of transferring information in one way or another. If the code table is known only to the transmitter and receiver, then a rather primitive cipher is obtained, which is easily amenable to frequency analysis. But if a person is far from the theory of coding and is not familiar with the frequency analysis of text, then it is rather problematic for him to guess such ciphers.

A1Z26

The simplest cipher. It is called A1Z26 or in the Russian version A1Я33. Alphabet letters are replaced with their ordinal numbers.

"NoZDR" can be encrypted as 14-15-26-4-18 or 1415260418.

Morse code

Letters, numbers and some signs are associated with a set of dots and dashes, which can be transmitted by radio, sound, knocking, light telegraph and signaling flags. Since sailors have a corresponding flag associated with each letter, it is possible to transmit a message with flags.

Braille

Braille is a tactile reading system for the blind, made up of six-point characters called cells. The cell is three points high and two points wide.

Different braille characters are formed by placing dots at different positions within a cell.

For convenience, the points are described when reading as follows: 1, 2, 3 from the left from top to bottom and 4, 5, 6 from the right from top to bottom.

When compiling the text, the following rules are adhered to:

    one cell is skipped between words (space);

    no cell is skipped after the comma and semicolon;

    a dash is written together with the previous word;

    the number is preceded by a digital sign.

Code Pages

In computer quests and riddles, you can encode letters according to their codes in various code pages - tables used on computers. For Cyrillic texts, it is best to use the most common encodings: Windows-1251, KOI8, CP866, MacCyrillic. Although for complex encryption, you can choose something more exotic.

You can encode with hexadecimal numbers, or you can convert them to decimal. For example, the letter E in KOI8-R has the code B3 (179), in CP866 it is F0 (240), and in Windows-1251 it is A8 (168). And you can search for letters in the right tables for a match in the left ones, then the text will turn out to be typed in "krakozyabrami" like èαᬫº∩íαδ (866 → 437) or Êðàêîçÿáðû (1251 → Latin-1).

And you can change the upper half of the characters to the lower one within one table. Then for Windows-1251 instead of "krakozyabra" you get "jp" jng ap ("instead of" HELICOPTER "-" BEPRNK (R ". Such a shift in the code page is a classic loss of the most significant bit in case of failures on mail servers. can be encoded with a reverse shift downward by 128 characters, and this encoding will be a variant of the cipher - ROT128, only not for the usual alphabet, but for the selected code page.

The exact time of the origin of the cipher is unknown, but some of the found records of this system date from the 18th century. Variations of this cipher were used by the Rosicrucian Order and the Freemasons. The latter used it in their secret documents and correspondence quite often, therefore the cipher began to be called the cipher of the Freemasons. Even on the gravestones of the Masons, you can see the inscriptions using this cipher. A similar encryption system was used during the US Civil War by the army of George Washington, as well as by prisoners in federal prisons in the US Confederations.

Below are two (blue and red) options for filling the grid of such ciphers. The letters are arranged in pairs, the second letter of the pair is drawn with a dotted symbol:

Copyright ciphers

Ciphers, where one character of the alphabet (letter, number, punctuation mark) corresponds to one (rarely more) graphic character, a great many have been invented. Most of them are designed for use in science fiction films, cartoons and computer games. Here is some of them:

Dancing men

One of the most famous copyright substitution ciphers is "". It was invented and described by the English writer Arthur Conan Doyle in one of his works about Sherlock Holmes. The letters of the alphabet are replaced with characters that look like men in various poses. In the book, the little men were not invented for all letters of the alphabet, so the fans creatively modified and reworked the symbols, and the following code was obtained:

Thomas More's alphabet

But such an alphabet was described in his treatise "Utopia" by Thomas More in 1516:

Ciphers from the animated series "Gravity Falls"

Bill Shifra

Stanford Pines (Diary Writer)

Jedi alphabet from Star Wars

Alien alphabet from "Futurama"

Superman's krypton alphabet

Bionicle alphabets

Semantics(fr. sémantique from ancient Greek. σημαντικός - denoting) - the science of understanding certain signs, sequences of symbols and other conventions. This science is used in many fields: linguistics, proxemics, pragmatics, etymology, etc. I don’t know what these words mean and what all these sciences do. And it doesn't matter, I am interested in the question of applying semantics in the layout of sites.

The note

I will not touch on the term Semantic Web here. At first glance, it might seem that the Semantic Web and Semantic HTML Code themes are almost the same thing. But in fact, the Semantic Web is a rather philosophical concept and does not have much in common with the current reality.

Semantic layout - what is it?

In the language, each word has a specific meaning, purpose. When you say "sausage", you mean a food product that is minced meat (usually meat) in an oblong casing. In short, you mean sausage, not milk or green peas.

HTML is also a language, its "words", called tags, also have a certain logical meaning and purpose. Therefore, first of all semantic HTML code is a layout with the correct use of HTML tags, using them for their intended purpose, as they were conceived by the developers of the HTML language and web standards.

microformats.org is a community that works to bring the idealistic ideas of the Semantic Web to life by bringing page markup closer to those semantic ideals.

Why and who needs semantic layout at all?

If on my website information is displayed in the same way as on the design, why should you still break your brain and think about some semantics ?! This is extra work! Who needs it ?! Who will appreciate it besides another layout designer?

I often heard such questions. Let's figure it out.

Semantic HTML for Web Developers

Semantic code for users

Increases the availability of information on the site. This is primarily important for alternative agents such as:

  • semantic code directly affects the amount of HTML code. Less code -> easier pages -> load faster, less RAM is required on the user side, less traffic, less database size. The site becomes faster and less expensive.
  • voice browsers for which the tags and their attributes are important in order to pronounce the content correctly and with the necessary intonation, or vice versa, not to pronounce too much.
  • mobile devices which do not fully support CSS and therefore rely mainly on HTML code, displaying it on the screen according to the tags used.
  • printing devices even without additional CSS, the information will print better (closer to the design), and creating the perfect version for printing will turn into a few easy CSS manipulations.
  • in addition, there are devices and plugins that allow you to quickly navigate the document - for example, by headings in Opera.

Semantic HTML for machines

Search engines are constantly improving their search methods so that the results include the information that really looking for user. Semantic HTML facilitates this because lends itself to much better analysis - the code is cleaner, the code is logical (you can clearly see where the headers are, where the navigation is, where the content is).

Good content plus high-quality semantic layout is already a serious application for good positions in search engine results.

The semantics of HTML code is always a hot issue. Some developers try to always write semantic code. Others criticize dogmatic adherents. And some even have no idea what it is and why it is needed. Semantics are defined in HTML in tags, classes, IDs, and attributes that describe the purpose, but do not specify exactly the content that is contained in them. That is, we are talking about the separation of content and its format.

Let's start with an obvious example.

Bad code semantics

Article title
And the author
Inco Gnito.

Good code semantics

Article title

The text of the article, which was written by someone. Inco Gnito- its author.

Whether you think HTML5 is ready-to-use or not, most likely using the tag

in this case will be more attractive than the usual
indicating the class. The title of the article becomes the heading, the content becomes the paragraph, and the bold text becomes the tag .

But not everything is so clearly represented with HTML5 tags. Let's take a look at a set of class names and see if they meet the semantic requirements.

Not semantic code. This is a classic example. Every CSS workbench for modular grid uses these type of class names to define grid items. Whether it's "yui-b", "grid-4", or "spanHalf" —these names are closer to describing markup than describing content. However, their use in most cases is inevitable when working with templates of modular grids.

Semantic code. The footer has taken on an enduring meaning in web design. This is the footer of the page that contains elements such as repeating navigation, usage rights, author information, and so on. This class defines a group for all these elements without their description.

If you have switched to using HTML5, then it is better to use the element

in such cases. The remark applies to all other parts of the web page (the header must be
, side panel -

© 2021 hecc.ru - Computer technology news