Submodule 1.4: More elements

The span element

The <span> tag is used to group small part of a text.

Similar to <div>, is used to apply CSS or JavaScript rules.

However, in contrast with <div>, the span is an inline element. This means that it doesn’t add a line break. Thus, it can be used inside any element./

Example

The CSS rules:

<!DOCTYPE html>
<html lang="en">
  <head>
    <style>
      #cl1 {background:yellow;}
    </style>
  </head>
  <body>
    <p>This is not span text <span>but this is</span> and this isn't</p>
    <p>This is not span text <span id ="cl1">but this is</span> and this isn't</p>
  </body>
</html>

will create a page displayed as:

span tag