Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
"id": 985,
"boost": 1.0,
"title": "<span>",
"slug": "Web/HTML/Element/span",
"summary": "The HTML span element is a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang.",
"locale": "en-US",
"modified": "2020-01-02T07:21:45.905",
"content": "\n\nThe HTML &lt;span&gt; element is a generic inline container for phrasing content, which does not inherently represent anything. It can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang. It should be used only when no other semantic element is appropriate. &lt;span&gt; is very much like a &lt;div&gt; element, but &lt;div&gt; is a block-level element whereas a &lt;span&gt; is an inline element....\n\n\n\nThe source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone and send us a pull request.\n\n\n \n \n Content categories\n Flow content, phrasing content.\n \n \n Permitted content\n Phrasing content.\n \n \n Tag omission\n None, both the starting and ending tag are mandatory.\n \n \n Permitted parents\n Any element that accepts phrasing content, or any element that accepts flow content.\n \n \n Permitted ARIA roles\n Any\n \n \n DOM interface\n HTMLSpanElement (before HTML5, the interface was HTMLElement)\n \n \n\n\nAttributes\n\nThis element only includes the global attributes.\n\nExample 1\n\nHTML\n\n&lt;p&gt;&lt;span&gt;Some text&lt;/span&gt;&lt;/p&gt;\n\nResult\n\n\n\nExample 2\n\nHTML\n\n&lt;li&gt;&lt;span&gt;\n &lt;a href=\"portfolio.html\" target=\"_blank\"&gt;See my portfolio&lt;/a&gt;\n&lt;/span&gt;&lt;/li&gt;\n\n\nCSS\n\nli span {\n background: gold;\n }\n\n\nResult\n\n\n\nSpecifications\n\n\n \n \n Specification\n Status\n Comment\n \n \n \n \n HTML Living StandardThe definition of '&lt;span&gt;' in that specification.\n Living Standard\n \n \n \n HTML5The definition of '&lt;span&gt;' in that specification.\n Recommendation\n The DOM interface is now HTMLSpanElement.\n \n \n HTML 4.01 SpecificationThe definition of '&lt;span&gt;' in that specification.\n Recommendation\n \n \n \n\n\nBrowser compatibility\n\nThe compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out and send us a pull request.\n\nUpdate compatibility data on GitHubDesktopMobileChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetspanChrome\n Full support\n \n YesEdge\n Full support\n \n 12Firefox\n Full support\n \n 1IE\n Full support\n \n YesOpera\n Full support\n \n YesSafari\n Full support\n \n YesWebView Android\n Full support\n \n YesChrome Android\n Full support\n \n YesFirefox Android\n Full support\n \n 4Opera Android\n Full support\n \n YesSafari iOS\n Full support\n \n YesSamsung Internet Android\n Full support\n \n YesLegend\n \n Full support\n \u00a0\n Full support\n\nSee also\n\n\n HTML &lt;div&gt; element\n",
"tags": [
"HTML:Flow content",
"HTML text-level semantics"
"kumascript_macros": [
"css_classnames": [
"html_attributes": [
"class=\"bc-head-txt-label bc-head-icon-chrome\"",
"class=\"bc-head-txt-label bc-head-icon-chrome_android\"",
"class=\"bc-head-txt-label bc-head-icon-edge\"",
"class=\"bc-head-txt-label bc-head-icon-firefox\"",
"class=\"bc-head-txt-label bc-head-icon-firefox_android\"",
"class=\"bc-head-txt-label bc-head-icon-ie\"",
"class=\"bc-head-txt-label bc-head-icon-opera\"",
"class=\"bc-head-txt-label bc-head-icon-opera_android\"",
"class=\"bc-head-txt-label bc-head-icon-safari\"",
"class=\"bc-head-txt-label bc-head-icon-safari_ios\"",
"class=\"bc-head-txt-label bc-head-icon-samsunginternet_android\"",
"class=\"bc-head-txt-label bc-head-icon-webview_android\"",
"class=\"bc-level bc-level-yes only-icon\"",
"class=\"bc-level-yes only-icon\"",
"class=\"bc-supports-yes bc-browser-chrome\"",
"class=\"bc-supports-yes bc-browser-chrome_android\"",
"class=\"bc-supports-yes bc-browser-edge\"",
"class=\"bc-supports-yes bc-browser-firefox\"",
"class=\"bc-supports-yes bc-browser-firefox_android\"",
"class=\"bc-supports-yes bc-browser-ie\"",
"class=\"bc-supports-yes bc-browser-opera\"",
"class=\"bc-supports-yes bc-browser-opera_android\"",
"class=\"bc-supports-yes bc-browser-safari\"",
"class=\"bc-supports-yes bc-browser-safari_ios\"",
"class=\"bc-supports-yes bc-browser-samsunginternet_android\"",
"class=\"bc-supports-yes bc-browser-webview_android\"",
"class=\"bc-supports-yes bc-supports\"",
"class=\"bc-table bc-table-web\"",
"class=\"brush: css\"",
"class=\"brush:html; gutter:false\"",
"class=\"deprecatedelement obsoleteelement\"",
"class=\"interactive tabbed-shorter\"",
"class=\"live-sample-frame sample-code-frame\"",
"class=\"obsoleteelement deprecatedelement\"",
"title=\"<frame> is an html element which defines a particular area in which another html document can be displayed. a frame should be used within a <frameset>.\"",
"title=\"<isindex> is an obsolete html element that puts a text field in a page for querying the document.\"",
"title=\"<spacer> is an obsolete html element which allowed insertion of empty spaces on pages. it was devised by netscape to accomplish the same effect as a single-pixel layout image, which was something web designers used to use to add white spaces to web pages without actually using an image. however, <spacer> no longer supported by any major browser and the same effects can now be achieved using simple css. \"",
"title=\"dom: the dom (document object model) is an api that represents and interacts with any html or xml document. the dom is a document model loaded in the browser and representing the document as a node tree, where each node represents part of the document (e.g. an element, text string, or comment).\"",
"title=\"full support\"",
"title=\"html5: the latest stable release of html, html5 takes html from a simple markup for structuring a document to a full app development platform. among other features, html5 includes new elements and javascript apis to enhance storage, multimedia, and hardware access.\"",
"title=\"mdn web docs interactive example\"",
"title=\"redirect heading elements [en-us]\"",
"title=\"the html <a> element (or anchor element), along with it's href attribute, creates a hyperlink to other web pages, files, locations within the same page, email addresses, or any other url.\"",
"title=\"the html <address> element indicates that the enclosed html provides contact information for a person or people, or for an organization.\"",
"title=\"the html <area> element defines a hot-spot region on an image, and optionally associates it with a hypertext link. this element is used only within a <map> element.\"",
"title=\"the html <article> element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable\"",
"title=\"the html <aside> element represents a portion of a document whose content is only indirectly related to the document's main content.\"",
"title=\"the html <audio> element is used to embed sound content in documents. it may contain one or more audio sources, represented using the src attribute or the <source> element:\u00a0the browser will choose the most suitable one. it can also be the destination for streamed media, using a mediastream.\"",
"title=\"the html <base> element specifies the base url to use for all relative urls contained within a document. there can be only one <base> element in a document.\"",
"title=\"the html <blockquote> element (or html block quotation element) indicates that the enclosed text is an extended quotation. usually, this is rendered visually by indentation (see notes for how to change it). a url for the source of the quotation may be given using the cite attribute, while a text representation of the source can be given using the <cite> element.\"",
"title=\"the html <body> element represents the content of an html\u00a0document. there can be only one <body> element in a document.\"",
"title=\"the html <br> element produces a line break in text (carriage-return). it is useful for writing a poem or an address, where the division of lines is significant.\"",
"title=\"the html <button> element represents a clickable button, which can be used in forms or anywhere in a document that needs simple, standard button functionality.\"",
"title=\"the html <code> element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code.\"",
"title=\"the html <col> element defines a column within a table and is used for defining common semantics on all common cells. it is generally found within a <colgroup> element.\"",
"title=\"the html <colgroup> element defines a group of columns within a table.\"",
"title=\"the html <content> element\u2014an obsolete part of the web components suite of technologies\u2014was used inside of shadow dom as an insertion point, and wasn't meant to be used in ordinary html.\"",
"title=\"the html <data> element links a given content with a machine-readable translation. if the content is time- or date-related, the <time> element must be used.\"",
"title=\"the html <datalist> element contains a set of <option> elements that represent the values available for other controls..\"",
"title=\"the html <del> element represents a range of text that has been deleted from a document.\"",
"title=\"the html <dialog> element represents a dialog box or other interactive component, such as an inspector or window.\"",
"title=\"the html <dl> element represents a description list. the element encloses a list of groups of terms (specified using the <dt> element) and descriptions (provided by <dd> elements). common uses for this element are to implement a glossary or to display metadata (a list of key-value pairs).\"",
"title=\"the html <dt> element specifies a term in a description or definition list, and as such must be used inside a <dl> element.\"",
"title=\"the html <em> element marks text that has stress emphasis. the <em> element can be nested, with each level of nesting indicating a greater degree of emphasis.\"",
"title=\"the html <embed> element embeds external content at the specified point in the document. this content is provided by an external application or other source of interactive content such as a browser plug-in.\"",
"title=\"the html <fieldset> element is used to group several controls as well as labels (<label>) within a web form.\"",
"title=\"the html <figcaption> or figure caption element represents a caption or legend describing the rest of the contents of its parent <figure> element.\"",
"title=\"the html <figure> (figure with optional caption) element represents self-contained content, potentially with an optional caption, which is specified using the (<figcaption>) element.\"",
"title=\"the html <footer> element represents a footer for its nearest sectioning content or sectioning root element. a footer typically contains information about the author of the section, copyright data or links to related documents.\"",
"title=\"the html <form> element represents a document section that contains interactive controls for submitting information to a web server.\"",
"title=\"the html <frameset> element is used to contain <frame> elements.\"",
"title=\"the html <head> element contains machine-readable information (metadata) about the document, like its title, scripts, and style sheets.\"",
"title=\"the html <header> element represents introductory content, typically a group of introductory or navigational aids. it may contain some heading elements but also a logo, a search form, an author name, and other elements.\"",
"title=\"the html <hgroup> element represents a multi-level heading for a section of a document. it groups a set of <h1>\u2013<h6> elements.\"",
"title=\"the html <hr> element represents a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section.\"",
"title=\"the html <html> element represents the root (top-level element) of an html document, so it is also referred to as the root element. all other elements must be descendants of this element.\"",
"title=\"the html <i> element represents a range of text that is set off from the normal text for some reason. some examples include technical terms, foreign language phrases, or fictional character thoughts. it is typically displayed in italic type.\"",
"title=\"the html <img> element embeds an image into the document. it is a replaced element.\"",
"title=\"the html <input> element is used to create interactive controls for web-based forms in order to accept data from the user; a wide variety of types of input data and control widgets are available, depending on the device and user agent.\"",
"title=\"the html <ins> element represents a range of text that has been added to a document.\"",
"title=\"the html <keygen> element exists to facilitate generation of key material, and submission of the public key as part of an html form. this mechanism is designed for use with web-based certificate management systems. it is expected that the <keygen> element will be used in an html form along with other information needed to construct a certificate request, and that the result of the process will be a signed certificate.\"",
"title=\"the html <label> element represents a caption for an item in a user interface.\"",
"title=\"the html <legend> element represents a caption for the content of its parent <fieldset>.\"",
"title=\"the html <li> element is used to represent an item in a list.\"",
"title=\"the html <main> element represents the dominant content of the <body> of a document. the main content area consists of content that is directly related to or expands upon the central topic of a document, or the central functionality of an application.\"",
"title=\"the html <map> element is used with <area> elements to define an image map (a clickable link area).\"",
"title=\"the html <marquee> element is used to insert a scrolling area of text. you can control what happens when the text reaches the edges of its content area using its attributes.\"",
"title=\"the html <menu> element represents a group of commands that a user can perform or activate. this includes both list menus, which might appear across the top of a screen, as well as context menus, such as those that might appear underneath a button after it has been clicked.\"",
"title=\"the html <menuitem> element represents a command that a user is able to invoke through a popup menu. this includes context menus, as well as menus that might be attached to a menu button.\"",
"title=\"the html <meta> element represents metadata that cannot be represented by other html meta-related elements, like <base>, <link>, <script>, <style> or <title>.\"",
"title=\"the html <meter> element represents either a scalar value within a known range or a fractional value.\"",
"title=\"the html <nav> element represents a section of a page whose purpose is to provide navigation links, either within the current document or to other documents. common examples of navigation sections are menus, tables of contents, and indexes.peter change 5.\"",
"title=\"the html <noscript> element defines a section of html to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.\"",
"title=\"the html <object> element represents an external resource, which can be treated as an image, a nested browsing context, or a resource to be handled by a plugin.\"",
"title=\"the html <ol> element represents an ordered list of items, typically rendered as a numbered list.\"",
"title=\"the html <optgroup> element creates a grouping of options within a <select> element.\"",
"title=\"the html <option> element is used to define an item contained in a <select>, an <optgroup>, or a <datalist>\u00a0element. as such,\u00a0<option>\u00a0can represent menu items in popups and other lists of items in an html document.\"",
"title=\"the html <p> element represents a paragraph.\"",
"title=\"the html <param> element defines parameters for an <object> element.\"",
"title=\"the html <picture> element contains zero or more <source> elements and one <img> element to provide versions of an image for different display/device scenarios.\"",
"title=\"the html <pre> element represents preformatted text which is to be presented exactly as written in the html file.\"",
"title=\"the html <progress> element displays an indicator showing the completion progress of a task, typically displayed as a progress bar.\"",
"title=\"the html <q> element indicates that the enclosed text is a short inline quotation. most modern browsers implement this by surrounding the text in quotation marks. \"",
"title=\"the html <ruby> element represents a ruby annotation. ruby annotations are for showing pronunciation of east asian characters.\"",
"title=\"the html <s> element renders text with a strikethrough, or a line through it. use the <s> element to represent things that are no longer relevant or no longer accurate. however, <s> is not appropriate when indicating document edits; for that, use the <del> and <ins> elements, as appropriate.\"",
"title=\"the html <script> element is used to embed or reference executable code; this is typically used to embed or refer to javascript code.\"",
"title=\"the html <section> element represents a standalone section \u2014 which doesn't have a more specific semantic element to represent it \u2014 contained within an html document.\"",
"title=\"the html <select> element represents a control that provides a menu of options\"",
"title=\"the html <shadow> element\u2014an obsolete part of the web components technology suite\u2014was intended to be used as a shadow dom insertion point.\"",
"title=\"the html <slot> element\u2014part of the web components technology suite\u2014is a placeholder inside a web component that you can fill with your own markup, which lets you create separate dom trees and present them together.\"",
"title=\"the html <small> element makes the text font size one size smaller (for example, from large to medium, or from small to x-small) down to the browser's minimum font size.\u00a0 in html5, this element is repurposed to represent side-comments and small print, including copyright and legal text, independent of its styled presentation.\"",
"title=\"the html <source> element specifies multiple media resources for the <picture>, the <audio> element, or the <video> element.\"",
"title=\"the html <span> element is a generic inline container for phrasing content, which does not inherently represent anything. it can be used to group elements for styling purposes (using the class or id attributes), or because they share attribute values, such as lang.\"",
"title=\"the html <strike> element\u00a0(or\u00a0html strikethrough element) places\u00a0a strikethrough (horizontal line) over text.\"",
"title=\"the html <style> element contains style information for a document, or part of a document.\"",
"title=\"the html <table> element represents tabular data \u2014 that is, information presented in a two-dimensional table comprised of rows and columns of cells containing data.\"",
"title=\"the html <td> element defines a cell of a table that contains data. it participates in the table model.\"",
"title=\"the html <textarea> element represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text, for example a comment on a review or feedback form.\"",
"title=\"the html <tfoot> element defines a set of rows summarizing the columns of the table.\"",
"title=\"the html <th> element defines a cell as header of a group of table cells. the exact nature of this group is defined by the scope and headers attributes.\"",
"title=\"the html <thead> element defines a set of rows defining the head of the columns of the table.\"",
"title=\"the html <time> element represents a specific period in time.\"",
"title=\"the html <tr> element defines a row of cells in a table. the row's cells can then be established using a mix of <td> (data cell) and <th> (header cell) elements.the html <tr> element specifies that the markup contained inside the <tr> block comprises one row of a table, inside which the <th> and <td> elements create header and data cells, respectively, within the row.\"",
"title=\"the html <track> element is used as a child of the media elements <audio> and <video>. it lets you specify timed text tracks (or time-based data), for example to automatically handle subtitles. the tracks are formatted in webvtt format (.vtt files) \u2014 web video text tracks or\u00a0timed text markup language (ttml).\"",
"title=\"the html <ul> element represents an unordered list of items, typically rendered as a bulleted list.\"",
"title=\"the html <wbr> element represents a word break opportunity\u2014a position within text where the browser may optionally break a line, though its line-breaking rules would not otherwise create a break at that location.\"",
"title=\"the html abbreviation element (<abbr>) represents an abbreviation or acronym; the optional title attribute can provide an expansion or description for the abbreviation.\"",
"title=\"the html acronym element (<acronym>) allows authors to clearly indicate a sequence of characters that compose an acronym or abbreviation for a word. this element has been removed in html5. use\u00a0<abbr> instead.\"",
"title=\"the html bidirectional isolate element (<bdi>)\u00a0 tells the browser's bidirectional algorithm to treat the text it contains in isolation from its surrounding text.\"",
"title=\"the html bidirectional text override element (<bdo>) overrides the current directionality of text, so that the text within is rendered in a different direction.\"",
"title=\"the html blink element (<blink>) is a non-standard element which causes the enclosed text to flash slowly.\"",
"title=\"the html bring attention to element (<b>)\u00a0 is used to draw the reader's attention to the element's contents, which are not otherwise granted special importance.\"",
"title=\"the html citation element (<cite>) is used to describe a reference to a cited creative work, and must include the title of that work.\"",
"title=\"the html content division element (<div>) is the generic container for flow content. it has no effect on the content or layout until styled using css.\"",
"title=\"the html content template (<template>) element is a mechanism for holding html that is not to be rendered immediately when a page is loaded but may be instantiated subsequently during runtime using javascript.\"",
"title=\"the html definition element (<dfn>) is used to indicate the term being defined within the context of a definition phrase or sentence.\"",
"title=\"the html details element (<details>) creates a disclosure widget in which information is visible only when the widget is toggled into an \"open\" state.\"",
"title=\"the html disclosure summary element (<summary>) element specifies a summary, caption, or legend for a <details> element's disclosure box.\"",
"title=\"the html example element (<xmp>) renders text between the start and end tags without interpreting the html in between and using a monospaced font. the html2 specification recommended that it should be rendered wide enough to allow 80 characters per line.\"",
"title=\"the html external resource link element (<link>) specifies relationships between the current document and an external resource. this element is most commonly used to link to stylesheets, but is also used to establish site icons (both \"favicon\" style icons and mobile home screen/app icons) among other things.\"",
"title=\"the html font element (<font>) defines the font size, color and face for its content.\"",
"title=\"the html inline frame element (<iframe>) represents a nested browsing context, embedding another html page into the current one.\"",
"title=\"the html keyboard input element (<kbd>) represents a span of inline text denoting textual user input from a keyboard, voice input, or any other text entry device.\"",
"title=\"the html listing element (<listing>) renders text between the start and end tags without interpreting the html in between and using a monospaced font. the html 2 standard recommended that lines shouldn't be broken when not greater than 132 characters.\"",
"title=\"the html mark text element (<mark>) represents text which is marked or highlighted for reference or notation purposes, due to the marked passage's relevance or importance in the enclosing context.\"",
"title=\"the html output element (<output>) is a container element into which a site or app can inject the results of a calculation or the outcome of a user action.\"",
"title=\"the html plaintext element (<plaintext>) renders everything following the start tag as raw text, ignoring any following html.\"",
"title=\"the html ruby base (<rb>) element is used to delimit the base text component of a\u00a0 <ruby> annotation, i.e. the text that is being annotated.\"",
"title=\"the html ruby fallback parenthesis (<rp>) element is used to provide fall-back parentheses for browsers that do not support display of ruby annotations using the <ruby> element.\"",
"title=\"the html ruby text (<rt>) element specifies the ruby text component of a ruby annotation, which is used to provide pronunciation, translation, or transliteration information for east asian typography. the <rt> element must always be contained within a <ruby> element.\"",
"title=\"the html ruby text container (<rtc>) element embraces semantic annotations of characters presented in a ruby of <rb> elements used inside of <ruby> element. <rb> elements can have both pronunciation (<rt>) and semantic (<rtc>) annotations.\"",
"title=\"the html sample element (<samp>) is used to enclose inline text which represents sample (or quoted) output from a computer program.\"",
"title=\"the html strong importance element (<strong>) indicates that its contents have strong importance, seriousness, or urgency. browsers typically render the contents in bold type.\"",
"title=\"the html subscript element (<sub>) specifies inline text which should be displayed as subscript for solely typographical reasons.\"",
"title=\"the html superscript element (<sup>) specifies inline text which is to be displayed as superscript for solely typographical reasons.\"",
"title=\"the html table body element (<tbody>) encapsulates a set of table rows (<tr> elements), indicating that they comprise the body of the table (<table>).\"",
"title=\"the html table caption element (<caption>) specifies the caption (or title) of a table, and if used is always the first child of a <table>.\"",
"title=\"the html title element (<title>) defines the document's title that is shown in a browser's title bar or a page's tab.\"",
"title=\"the html unarticulated annotation element (<u>) represents a span of inline text which should be rendered in a way that indicates that it has a non-textual annotation.\"",
"title=\"the html variable element (<var>) represents the name of a variable in a mathematical expression or a programming context.\"",
"title=\"the html video element (<video>) embeds a media player which supports video playback into the document.\"",
"title=\"the htmlelement interface represents any html element. some elements directly implement this interface, while others implement it via an interface that inherits it.\"",
"title=\"the htmlspanelement interface represents a <span> element and derives from the htmlelement interface, but without implementing any additional properties or methods.\"",
"title=\"the internet explorer only html background sound element (<bgsound>) sets up a sound file to play in the background while the page is used; use <audio> instead.\"",
"title=\"the non-standard, obsolete html <nobr> element prevents the text it contains from automatically wrapping across multiple lines, potentially resulting in the user having to scroll horizontally to see the entire width of the text.\"",
"title=\"the obsolete html applet element (<applet>) embeds a java applet into the document; this element has been deprecated in favor of <object>.\"",
"title=\"the obsolete html base font element (<basefont>) sets a default font face, size, and color for the other elements which are descended from its parent element.\"",
"title=\"the obsolete html big element (<big>) renders the enclosed text at a font size one level larger than the surrounding text (medium becomes large, for example).\"",
"title=\"the obsolete html center element (<center>) is a block-level element that displays its block-level or inline contents centered horizontally within its containing element.\"",
"title=\"the obsolete html directory element (<dir>) is used as a container for a directory of files and/or folders, potentially with styles and icons applied by the user agent.\"",
"title=\"the obsolete html no frames or frame fallback element, <noframes>, provides content to be presented in browsers that don't support (or have disabled support for) the <frame> element.\"",
"title=\"the obsolete html teletype text element (<tt>) creates inline text which is presented using the user agent's default monospace font face.\"",
"title=\"the\u00a0html <dd> element provides the details about or the definition of the preceding term (<dt>) in a description list (<dl>).\"",
"title=\"use the html <canvas> element with either the canvas scripting api or the webgl api to draw graphics and animations.\"",
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.