Skip to main content
Humanities LibreTexts

9.2: Tag Rules

  • Page ID
    51581
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    HTML is a language, and it, as all languages do, has rules that make it make sense to the web browser. Just as the English language doesn't make sense when you break grammar rules, neither does HTML when you break tag rules. The difference is, most English speakers will still understand what you are trying to say when you break a grammar rule; the web browser will not understand when you break a tag rule. So let's look at some of these rules.

    When you look at a line of HTML, you'll see information enclosed in brackets < > throughout the code. This denotes a tag. A tag is what tells web browsers what each item on the page is; it tells the web browser how to classify that information. For example, a paragraph would be classified by a

    tag.

    Rule #1

    Most tags have an opening tag and a closing tag that surround the information it is classifying or effecting. An opening tag is just the brackets with the tag enclosed, like so:

    . A closing tag is the same thing, except there is a forward slash at the front of the tag, like so: </p>. When tagging a paragraph with the

    tag, it would look like the example.

    This is a paragraph about how to properly tag a paragraph. To tag a paragraph, you have to start with an opening paragraph tag, type the paragraph, and then end with a closing paragraph tag. This is how most sections of simple paragraph text are tagged. </p>

    Rule #2

    Rule #1 does not always apply. Not all tags have to have a closing tag, and you just have to remember those. We will learn about some basic tags in the next section, where we talk about a few that do not require a closing tag.

    Rule #3

    Opening and closing tags must be nested to work. That is, the last tag you open should be the first tag you close, as shown in the example.

    <body>

    .This is a paragraph in the body of the webpage. As you see, I opened the body tag first, and then the paragraph tag; if I am nesting the tags, then I have to close the paragraph tag first, and then close the body tag.</p>

    </body>


    This page titled 9.2: Tag Rules is shared under a CC BY license and was authored, remixed, and/or curated by Tiffani Reardon, Tammy Powell, Jonathan Arnett, Monique Logan, & Cassie Race.

    • Was this article helpful?