HTML abbreviations. Less known semantic elements. Default style

💖 Do you like it? Share the link with your friends

The code element is used to specify computer code or a programming language such as PHP, JavaScript, CSS, XML, etc. For short snippets within a sentence, you can simply place the element around the code snippet like this:

onclick directly in the HTML.

For larger code samples that span multiple lines, you can use preformatted blocks, as shown in Lecture 15, “Marking up Text Content in HTML.”

Although there is no specific method for indicating which programming language or the code is shown in a code element, the class attribute can be used. A common practice (mentioned in the HTML 5 draft) is to use the language- prefix and then add the name of the language. So the example above would look like this:

It is bad form to use event handlers like onclick directly in the HTML.

Some programming languages ​​have names that are not easily represented in classes, such as C# (C-sharp). The right way The entry in this case will be "class="language-c\#"" , which can create difficulties and lead to typos. I would recommend using a class consisting of only letters and hyphens, and writing it in its entirety. Therefore, in this case, it is better to use "class="language-csharp"" .

Computer interaction output

Two elements samp and kbd can be used for input and output interaction with a computer program. For example:

One common method of determining if a computer is connected to the internet is to use the computer program ping to see if a computer is likely to be running is reachable.

kittaghy% ping -o google.com
 PING google.com (64.233.187.99): 56 data bytes 64 bytes from 64.233.187.99: icmp_seq=0 ttl=242 time=108.995 ms --- google.com ping statistics --- 1 packets transmitted, 1 packets received, 0  % packet loss round-trip min/avg/max/stddev = 108.995/108.995/108.995/0.000 ms

Element samp indicates a sample output from a computer program. As shown in this example, Various types output can be specified using class attribute. However, there is no widely accepted agreement on what kinds of classes to use.

The kbd element specifies the input of the user's interaction with the computer. Although this is traditionally keyboard input (hence the abbreviation "kbd"), it should also be used to indicate other types of input, such as voice input.

Variables

The var element is used to specify variables in text content. It may include algebraic mathematical expressions or be in program code. For example:

The value of x in 3 x+2=14 is 4.

my $welcome= "Hello world!";

Citation

The cite element is used to indicate where nearby content comes from—when quoting a person, book, or other publication, or generally when referring people to another source, that source should be placed within a cite element. For example:

The saying Everything should be made as simple as possible, but not simpler is often attributed to Albert Einstein, but it actually a paraphrasing of a quote which is much less easy to understand.

Description

Tag indicates that the sequence of characters is an abbreviation. Using the title attribute, the abbreviation is deciphered, which allows those people who are not familiar with it to understand the abbreviation. In addition, search engines index the full-text version of the abbreviation, which can be used to improve the ranking of the document.

Browsers do not highlight text inside , with the exception of Opera before version 15, which adds dotted underlines to text.

Syntax

Text

Attributes

Adds a tooltip to the text in which you can explain the abbreviation.

Closing tag

Required.

HTML5 IE Cr Op Sa Fx

Tag ABBR

CGI denotes the protocol by which any external programs interact with the web server. Using CGI, you can run programs on the server in any programming language and display the result of their actions as a web page.



The result of this example is shown in Fig. 1.

Rice. 1. Type of tooltip when hovering the mouse over the abbreviation text

Browsers

Internet Explorer browser up to version 6 does not support the tag , it is recommended to use the tag instead .

The HTML Abbreviation element( ) represents an abbreviation or acronym; the optional title attribute can provide an expansion or description for the abbreviation. If present, title must contain this full description and nothing else.

The source for this interactive example is stored in a GitHub repository. If you"d like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

Accessibility concerns

Spelling out the acronym or abbreviation in full the first time it is used on a page is beneficial for helping people understand it, especially if the content is technical or industry jargon.

Example

JavaScript Object Notation ( JSON) is a lightweight data-interchange format.

This is especially helpful for people who are unfamiliar with the terminology or concepts discussed in the content, people who are new to the language, and people with cognitive concerns.

Specifications

Specification Status Comment
HTML Living Standard
The definition of " "in that specification.
Living Standard
HTML5
The definition of " "in that specification.
Recommendation
HTML 4.01 Specification
The definition of " "in that specification.
Recommendation

Browser compatibility

The compatibility table in this page is generated from structured data. If you"d like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

Update compatibility data on GitHub

DesktopMobile
ChromeEdgeFirefoxInternet Explorer OperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
abbrChrome Full support 2Edge Full support YesFirefox Full support 1

Notes

Full support 1

Notes

Notes Before Firefox 4, this element implemented the HTMLSpanElement interface instead of the standard HTMLElement interface.
IE Full support 7Opera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support Full support See implementation notes. See implementation notes.

See also

The web today is increasingly semantic. But what does "semantic" mean? Why is it important?

Semantic HTML expresses the meaning of a document. It's more about what the text is than what it looks like. Good semantic markup helps both humans and computers better understand the content of a document and its context.

Semantic markup is much easier to interpret. She's friendly search engine optimization. Works great with modern browsers, reducing the amount of code needed to express content and increasing the readability of that code.

Ok, so semantic markup is good, but how to use it. The best place to start is by replacing regular tags with more expressive tags. Let's look at eight elements that will allow you to get into this game.

Like its blocky cousin
, tag used to indicate citation.

Why not just use quotes? Quotation marks do not always imply quotation. Sometimes they are used for emphasis, irony or to indicate the name of something - and in this context, they are used correctly. However, if you quote something, clearly expresses your intention.

And

In the good old days, tags And denoted text in italics and bold, respectively. When the idea of ​​separating semantics from representation began to gain traction, these tags began to be viewed with suspicion. They were replaced with tags And , denoting emphasis and strong emphasis, respectively.

In HTML5, these tags finally have a distinct semantic interpretation. Tag Text that has a different tone or mood is flagged. This is useful, for example, for describing thoughts or technical terms. Tag marks text that is stylistically different from regular text but does not have any distinct semantic meaning. How is this different from using ? The key is that does not carry any semantically distinct meaning.

used for abbreviations! It can be especially useful in documents where there are a lot of them. This tag has an optional attribute title, in which you can specify
full version text.

lol idk g2g ttyl

Let's take a look at the classic date localization problem. In the USA, October 5, 2013 is written as 10/05/13, in Britain it is 05/10/13, in South Africa it is 2013/10/05, in Russia it is 05/10/13. All of these options make it extremely difficult to automatically recognize dates.

Tag allows you to specify the date and time in a machine-readable format. The previous example might look something like this: . HTML parsers will be able to accurately understand the date, regardless of the format in which we specified it. Tag also allows you to optionally specify time in 24 format: ;

Ever done this?

Three hundred pages of boring, useless text. The one thing you need to know and will never be able to find again if you don"t highlight it. More boring stuff…


No more. An element appeared in HTML5 , which marks text that is highlighted for reference purposes because of its importance.

Yes, . You are probably using , , maybe even , have you ever used other types? In HTML5 can be used with a whole bunch of new types:
  • email
  • number
  • range
  • search
  • color
This is great, but first you need to make sure your target browsers support all of this. This is still a problem.

Have you ever made a menu from an unnumbered list?

Don't do that again! For this there is

, which is an unordered list of commands. This tag has an attribute type, which can take the following values: popup or toolbar.

  • Open
  • Save
  • Quit
  • Bonus

    Most front-end developers use HTML when writing, but many do not know its true meaning. A non-breaking space does not break a line. This means that if two words are connected by a non-breaking space, they will always be together on the same line. Sometimes this is very important. Here are some examples:
    • Units: 12 m/s
    • Time: 8 PM
    • Proper names: Dairy Queen
    There is also a non-breaking hyphen ( ), for similar purposes.

    Finally

    HTML is becoming more and more semantic day by day. Using all of these elements is a good start to writing more accessible, readable markup. For a more complete picture, take a look

    tell friends