HTML <span> Tag Last Updated : 02 May, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report The HTML <span> tag is an inline container that is used to group and apply styles or scripts to specific parts of text or elements within a document. The <span> tag is inline, meaning it doesn't create a new line. It stays within the same line as the text around it.The <span> tag doesn’t change how the content looks on its own. It's used to apply styles or to control parts of content through JavaScript.Syntax<span class="">Some Text</span> Note: HTML <span> tag supports the Global attribute and Event Attributes.Examples of HTML <span> TagHere are a few examples of the HTML span Tag: Example 1: Reducing Code and Grouping Styles with <span>In this example, we use the <span> tag to apply CSS styles directly to specific content, reducing repetitive HTML attributes. This approach ensures cleaner code and a consistent style across elements. HTML <!DOCTYPE html> <html> <head> <title>GeeksforGeeks span tag</title> <!-- style for span tag --> <style> span { color: green; text-decoration: underline; font-style: italic; font-weight: bold; font-size: 26px; } </style> </head> <body> <span> GeeksforGeeks </span><br /> <span> GeeksforGeeks </span><br /> <span> GeeksforGeeks </span><br /> </body> </html> Output:Span tag with CSS styleExample 2: Inline Behavior of <span> ElementsIn this example, the <span> tag works as an inline element. Each <span> takes only the space required for its content, allowing multiple <span> elements to appear on the same line without affecting the overall layout. HTML <!DOCTYPE html> <html> <head> <title>GeeksforGeeks span tag</title> </head> <body> <!-- span tags with inline style/css --> <span style="background-color:powderblue;"> GfG </span> <span style="background-color: lightgray;"> -Contribute- </span> <span style="background-color: yellow;"> Article </span> <span style="background-color: lightgreen;"> GCET </span> </body> </html> Output:Span_tag_with_CSS_style<span> vs <div> tagBoth <span> and <div> are used as containers in HTML, there are key differences between them:<span><div>Inline elementBlock-level elementFor styling or grouping inline contentFor grouping block-level contentDoes not break the flow of textStarts on a new line and takes up full widthStyling or scripting small portions of textStructuring larger sections of contentBest Practices for Using the <span> TagAvoid Overuse: Don't overuse <span> tags unnecessarily. Only use it when you need to apply specific styles or functionality to small portions of text.Use Classes for Styling: Prefer using CSS classes over inline styles for better maintainability and cleaner code.Keep Accessibility in Mind: When using <span>, ensure that it doesn’t negatively affect the accessibility of your content. Add ARIA attributes if necessary for screen readers.Group Inline Content: Use <span> for grouping small portions of text or inline elements for styling or JavaScript manipulation without disrupting the layout.Browsers Support Browsers<span> tagYesYesYesYesYesConclusionThe HTML <span> tag is a versatile inline element used for applying styles or manipulating small sections of content. While it doesn't add any semantic meaning to the content, it plays an essential role in web development by providing hooks for styling and scripting. Comment More infoAdvertise with us R R_Raj Follow Improve Article Tags : Web Technologies HTML HTML-Tags Similar Reads HTML DOCTYPE Declaration HTML DOCTYPE (Document Type Declaration) is an instruction that appears at the beginning of an HTML document, before the <html> tag.Its primary role is to tell the web browser which version of HTML the page is written in, ensuring that the browser renders the content correctly. It is not an HT 4 min read HTML abbr Tag The <abbr> tag in HTML is used to represent abbreviations and provides additional information about them through the title attribute, which displays a tooltip when hovered over. It helps improve accessibility and SEO by offering context for the abbreviated text.It makes text clearer by explain 3 min read HTML acronym Tag The HTML <acronym> tag was used to define an acronym, providing a way to identify and explain abbreviated terms in web content. However, it's deprecated in favor of <abbr>, which serves the same purpose but is more semantically correct.Syntax: <acronym title=""> Short Form </acr 2 min read HTML < address> Tag The <address> tag in HTML is used to define contact information for the author or owner of a document or an article. It is typically used for information such as an address, email, or phone number.The <address> element is a block-level element by default.The content inside <address 3 min read HTML a Tag The <a> tag defines a hyperlink, which is used to link from one page to another. The most important attribute of the <a> element is the href attribute, which indicates the link's destination. This attribute determines where the user is directed upon clicking the link.HTML<a href="http 2 min read HTML applet Tag The applet tag in HTML was used to embed Java applets into any HTML document. The <applet> tag was deprecated in HTML 4.01, and its support has been completely discontinued starting from HTML 5. Alternatives available in HTML 5 are the <embed> and the <object> tags. Some browsers s 2 min read HTML area Tag This <area> tag is used in an HTML document to map a portion of an image to make it clickable by the end user. This specifies the location and size of the active region on an image, which can be clicked. Clicking on areas with href attributes directs to a specified URL or action.html<!DOCTY 3 min read HTML article Tag The HTML <article> tag defines a self-contained, independent piece of content like a blog post, news article, or comment. It is designed for content that can be independently distributed, shared, or reused, providing semantic meaning to the content.This tag is introduced in HTML5.HTML<!DOCT 3 min read HTML aside Tag The <aside> tag is used to describe the main object of the web page more shortly like a highlighter. It identifies the content that is related to the primary content of the web page but does not constitute the main intent of the primary page. The <aside> tag contains mainly author inform 2 min read HTML5 < audio> Tag The <audio> tag in HTML5 is used to embed audio content on a webpage. It allows you to play audio files like MP3, OGG, or WAV directly in the browser. The <audio> element provides attributes for controlling playback, such as play, pause, and volume.Using the <source> element enable 3 min read Like