[OPEN] Why is the unordered list structure different?


#1

So far it seems like the common way to end an HTML element is with the forward slash after the text < title/ >

When creating an unordered list it is the opposite < /ul >

Just wondering why this is the case and if there are any other similar quirks that may popup along the way?

Many thanks


#2

It’s the opposite? What do you mean by that?


#3

Sorry my original question embedded my examples as code in the msg.

I have spaced them out to illustrate my question better.


#4

No worries.

A couple things:

  • The title element requires an opening and closing tag, as far as I know:
<title>Website title</title>
  • The elements that do only require an opening tag are ‘self-contained’ and either don’t have any content in themselves (hr is a tricky one, but technically doesn’t have content, even though it can be styled with css);
<br/>
<hr/>

or source it from somewhere else:

<link type="text/css" rel="stylesheet"/>

Almost everything else* uses opening and closing tags as usual, enclosing their content:

<h1>Heading</h1>
<p>Paragraph text text text text text</p>
<a href="https://www.google.com/">Link</a>

*with exceptions:

<script src="script.js"></script>