Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

html
span
inline styling

How to use the HTML span tag

Educative Answers Team

The HTML <span> tag is used to group and style in-line elements.

Syntax

Various attributes can be set in the <span> tag. The general syntax to do so is as follows:

<p <span style="attribute: value.."> </p>

The <span> tag is supported by the following browsers:

svg viewer

Examples

  1. Let’s take a look at how we can use the <span> tag to highlight a certain part of the text:
  • HTML
  1. The <span> tag can also be used to group elements.

Consider the following example in which we wish to style particular sub-strings throughout the text. This can be achieved by creating a class and styling it as desired. The class name can then be used throughout the code within the <span> tag to assign it the particular properties.

  • HTML

RELATED TAGS

html
span
inline styling
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring