Home >Web Front-end >JS Tutorial >What does span mean in js
span tag can add styles, attributes or behaviors to text. It is used to: add styles, such as color and font size. Set attributes such as id, class, etc. Associated behaviors, such as clicks, hovers, etc. Mark text for further processing or citation.
span tag
The span tag is used to define the range of some text in the document, add styles to specific text, attribute or behavior. The syntax is as follows:
<code class="html"><span>文本</span></code>
Usage
span tag is mainly used for:
Example
The following example demonstrates the use of the span tag:
<code class="html"><p>这是我的一句话,我想将 "我" 字设置为粗体。</p> <script> document.querySelector("span").style.fontWeight = "bold"; </script></code>
Effect:
<code class="html">这是我的一句话,我想将 <span style="font-weight: bold;">我</span> 字设置为粗体。</code>
The difference from other tags
The difference between the span tag and other similar tags (such as em, strong, b) is that it does not affect the text semantics, but only adds styles or attributes. For example, the em tag emphasizes text, while the span tag simply styles the text.
The above is the detailed content of What does span mean in js. For more information, please follow other related articles on the PHP Chinese website!