What is the standard purpose of the span tag in HTML? -

Source: Internet
Author: User
Does text, images, and other things in span conform to the standard? Does text, images, and other things in span conform to the standard? Reply content: the element in the silent line.
Define the style of the content that is different from the style of the Section in the Section.
You can also use the span tag to meet the following conditions:
1. inline)
2. speechless
3. When you need to add a specific style or create a js hook for him

For example:
This is a paragraph. There are some special content to mark in the paragraph, such as red.
This is an arrow :.. You can define this class to display it as an arrow.
You can also enter 140 characters. J_zishu is used as the js hook label to combine the line elements in the document.
Used to combine in-row elements to format them through styles.

Standard attributes: id, class, title, style, dir, lang, xml: lang
The event attributes include onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, and onkeyup, which are non-semantic inline elements. Try to understand them + Chinese:
The DIV and SPAN elements, combined with the id and class attributes, can add containers for the document content. DIV provides block-level containers for the content, and SPAN provides intra-row containers. However, neither DIV nor SPAN assigns semantics to the content. Therefore, you can use these elements to combine style sheets, language attributes, and so on ...... To DIY the HTML language based on your preferences.

Http://W3.org Is abstract. Next, it makes up the following sentence: In general, you can use DIV or SPAN elements to combine id or class to implement specific semantics or structural effects, to supplement the tag objects not included in the HTML Tag: "customer", "phone number", and "emai [Note ①;

Note: ① for email, tags can be used in html5.
Suppose, for example, that we wanted to generate an HTML document based on a database of client information. since HTML does not include elements that identify objects such as "client", "telephone number", "email address", etc ., we use DIV and SPAN to achieve the desired structural and presentational effects. we might use the TABLE element as follows to structure the information:




Client information:






Last name: Boyera
First name: Stephen ANE
Tel: (212) 555-1212
Email: Sb@foo.org



Client information:






Last name: Lafon
First name: Yves
Tel: (617) 555-1212
Email: Yves@coucou.com

Then, in HTML5's document definition of SPAN,
Http://dev.w3.org/html5/spec/single-page.html#the-span-element

The definition of SPAN is much simpler:
The span element doesn't mean anything on its own, but can be useful when used together with the global attributes, e.g. class, lang, or dir. It represents its children.
In this example, a code fragment is marked up using span elements and class attributes so that its keywords and identifiers can be color-coded from CSS:
for (j = 0; j < 256; j++) {
i_t3 = (i_t3 & 0x1ffff) | (j << 17);
i_t6 = (((((((i_t3 >> 3) ^ i_t3) >> 1) ^ i_t3) >> 8) ^ i_t3) >> 5) & 0xff;
if (i_t6 == i_t1)
break;
}
The general idea is that the SPAN element itself is nothing, HoweverIt is useful when combining attributes such as: class, lang, or dir. It describes (document content. (Style: class + css; Content language: lang; dir: Text direction)

In addition: Answer the question under the title =. =

HTML 4.01 definition of contained elements:
It means a intra-row container ......
Definition of elements contained in HTML 5:
Contexts in which this element can be used:
Where phrasing content is expected.
Here is a phrasing content, which introduces:
Phrasing content is the text of the document, as well as elements that mark up that text at the intra-paragraph level. Runs of phrasing content form paragraphs.

Various labels .. Or click this link http://dev.w3.org/html5/spec/single-page.html#phrasing-content

Then it sums up a general rule, which means that any container that allows containing phrasing content must have at least one son node of the Text type and cannot be an inter-element whitespace [Note ②]; alternatively, its son node can be embedded content [Note ③]... (The del element is not related to span. It probably means that the child element in the del element will not be considered as its descendant by del's ancestor? Do elders of del not recognize descendants of del? =)
As a general rule, elements whose content model allows any phrasing content shoshould have either at least one descendant Text node that is not inter-element whitespace, or at least one descendant element node that is embedded content. for the purposes of this requirement, nodes that are descendants of del elements must not be counted as contributing to the ancestors of the del element.
Most elements that are categorized as phrasing content can only contain elements that are themselves categorized as phrasing content, not any flow content.
Note ②: inter-element whitespace: 1. text node with empty content 2. A text node composed of space characters. These two types of text nodes are considered as inter-element whitespace (space characters are generally special characters that implement functions such as space keys and tab keys)
The space characters are always allowed between elements. user agents represent these characters between elements in the source markup as text nodes in the DOM. empty text nodes and text nodes consisting of just sequences of those characters are considered inter-element whitespace.
The space characters, for the purposes of this specification, are U + 0020 SPACE, U + 0009 character tabulation (tab), U + 000A line feed (LF ), U + 000C form feed (FF), and U + 000D carriage return (CR ).

Note ③: embedded content, as its name implies.
Embedded content is content that imports another resource into the document, or content from another vocabulary that is inserted into the document.
  • Audio,
  • Canvas,
  • Embed,
  • Iframe,
  • Img,
  • Math,
  • Object,
  • Svg,
  • Video

PS: documents cannot be stopped once translated --

There are also some tips that use the inline features to achieve interaction or layout:
For example:
1. avoid misoperation when you click the block display label.
For example

The client browser will automatically give the block attribute to the tag. If you click the title wrapped by h1, the action will be triggered. When you click the title, it is still within the range of h1, it will also be triggered. In this case

You can solve the problem by adding one.
2. Keep the element in one row
Add content in different formats after some elements, but you can only use nesting instead of adding it to the next line.

Http://www.cnblogs.com/myparamita/archive/2011/02/15/1954838.html
Mi Hei
Any inline content in the inline content container is compliant with the standard.


Reference from http://w3.org/TR/html4 .. .
The DIV and SPAN elements, in conjunction with the id and class attributes, offer a generic mechanic for adding structure to documents. these elements define content to be inline (SPAN) or block-level (DIV) but impose no other presentational idioms on the content. thus, authors may use these elements in conjunction with style sheets, the lang attribute, etc ., to tailor HTML to their own needs and tastes.
Some elements are often modified using span
Because inline is not a block level, it is not used to destroy the Document Stream span as an inline element. It can also be used as a JS interaction. Inline elements include span, em, strong, small, del, and so on. Inline elements have no meaning. Generally, they are used to interact with JS. They have no function, however, after the span tag is selected, you can use ccs to modify the selected content in a unified format. Edit the format of the specified content.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.