HTML Basics

HTML Introduction HTML Basic HTML Comments HTML Tags/Elements HTML Attributes HTML Formatting HTML Block and Inline HTML Charsets HTML Classes HTML Colors HTML Div HTML Headings HTML Id HTML Iframes HTML Images HTML File Paths HTML Tables HTML Layout HTML Lists HTML Links <a> HTML Paragraphs HTML Quotations HTML JavaScript HTML Emojis HTML URL Encode HTML Entities HTML Computercode HTML Symbols HTML Styles

HTML Forms

HTML Forms HTML Form Elements HTML Form Attributes HTML Input Attributes HTML Input Regex HTML Input Form Attributes HTML Input Types

HTML SEO

HTML Head HTML Page Title HTML Responsive HTML Semantics HTML Favicon

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Audio HTML Video

HTML Reference

a abbr acronym address applet area article aside audio b base basefont bdi bdo big blockquote body br button canvas caption center cite code col colgroup data datalist dd del details dfn dialog dir div dl DOCTYPE dt em embed fieldset figcaption figure font footer form frame frameset h1_-_h6 head header hgroup hr html i iframe img input ins kbd label legend li link main map mark menu meta meter nav noframes noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script search section select small source span strike strong style sub summary sup svg table tbody td template textarea tfoot th thead time title tr track tt u ul var video wbr

HTML <span> Tag

The <span> tag in HTML is used to group inline elements and apply styles to them without affecting the overall layout of the page. It is a generic inline container that does not add any extra spacing or line breaks. You can use the tag to target specific sections of text within a larger block of content and style them differently. For example, if you want to highlight a particular word or phrase in a paragraph, you can wrap it in a tag and apply a different color, font size, or font style to it. This allows you to create visually distinct sections within your text without changing the structure of the content. Here is an example of how the <span> tag can be used in HTML:
<p>
This is a <span style="color: red;">red</span> word in a paragraph.
</p>
In this example, the word "red" is wrapped in a <span> tag with a style attribute that sets the color to red. This will only affect the color of the word "red" and not the rest of the text in the paragraph. The <span> tag can also be used in combination with CSS classes or IDs to apply more complex styles to specific sections of text. Here is an example with a CSS class:
<style>
.highlight {
  background-color: yellow;
  font-weight: bold;
  }
  </style>
<p>
  This is a <span class="highlight">highlighted</span> word in a paragraph.
</p>
In this example, the word "highlighted" is wrapped in a <span> tag with a class of "highlight", which applies a yellow background color and bold font weight to the text. Here are the main attributes of the <span> tag and their use:
Attribute Description
style Defines inline styles for the content within the tag
class Defines one or more classes for the content within the tag