HTML Tags for the Head and Body




CS174

Chris Pollett

Feb 8, 2021

Outline

Introduction

Standard XHTML 1.1 Document Structure

XML declarations:

<?xml version ="1.0" encoding="utf-8" ?>
<!-- as not supported by some old 
   browsers validators doesn't usually check this -->

SGML DOCTYPE. This says which Document Type Definition will be used:

<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.1//EN"
 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 

The XHTML document:

<html xmlns="http://www.w3.org/1999/xhtml" >
		<!-- might have namespaces for other things like SVG -->
<head>
	<title>name of my document</title></head>
<body><!--actually page stuff--></body>
</html>

Minimal HTML 5 Document

Where to Edit HTML

How to "run" your HTML

What does it mean for your HTML to "work"?

The head of an XHTML or HTML5 document

We have now looked at a simple HTML document. This consisted of a DOCTYPE declaration, an html tag pair with head and body tag pairs as its contents. The head has to have at least a title tag within it. Let's now examine what can go in the head and body tags pairs in detail, beginning by looking at the head tag:

Kinds of Meta Information

Heads of documents can also have (but are not required to have) meta tags.

<meta name="author" content="who wrote the page" />
<meta name="generator" content="ChrisTextTool" /> 
   <!--What software was used to generate this html -->
<meta name="description" content="how I would like the search 
   engines to describe my page. " />
<meta name="keywords" content="cool site" /> 
   <!--Key terms search engines should index this site with. 
    Unfortunately, not really used by search engines anymore -->
<meta name="robots" content="comma separated list of 
   what would like crawler to do" /> 
   <!-- Example commands NOINDEX, NOFOLLOW, NOCACHE, NOSNIPPET, NOODP, NOYDIR . 
     Some of these commands can also be specified in a robots.txt file. ROBOTS
     and these values are case insensitive.-->

Rather than use robots in the above you can also give directives for specific robots.

In addition to the above meta tags, we will see later in the semester how aspects of how the screen renders in a mobile phone can be affected by meta tags.

The WHATWG Meta Extensions page contains a relatively complete list of values for the name and content attribute.

More Meta Information

Quiz

Which of the following statements is true?

  1. In an HTTP request/response only the response is allowed to have a body.
  2. The World Wide Web is the collection of devices connected to the internet running the HTTP protocol.
  3. .txt is a mime type.

The body of a web page

More on Block level elements

What tags can go into the body of a web page?

<h1></h1> - <h6></h6>
are called heading tags. They are used to give a heading for a section of a web document. To be accessible the numbering of heading tags should be properly nested.
  <h1>heading1</h1> 
	<h2>heading 2</h2>
		<h3>heading</h3>
  <!--this is okay, should not do things like skip from an h2 
  to an h4 tag without an h3 tag in between. Screen readers use 
  these headings to extract a table of contents for the document -->
<p></p>
used to specify a paragraph. By default this is style'd with an indentation.
<div></div>
used to specify a related section of text. This tag is a very generic container tag that doesn't have very much semantic meaning. HTML 5 specifies several other block level container tags with more meaning: <header>, for text that is at the top of the document; <section>, for chapters, etc.; <figure>, for figures included in documents.
<blockquote></blockquote>
used to indent large quotations.
<ul></ul> <ol></ol>
unordered and ordered lists. Elements in list are specified with <li></li>. There are also <dl></dl> definition lists.
  <ul>
    <li>List Item 1</li>
    <li>List Item 2
      <ul>
        <li>Sub List Item</li>
      </ul>       
    </li>
  </ul>
  • List Item 1
  • List Item 2
    • Sub List Item
  <ol>
    <li>List Item 1</li>
    <li>List Item 2
      <ol>
        <li>Sub List Item </li>
      </ol>       
    </li>
  </ol>
  1. List Item 1
  2. List Item 2
    1. Sub List Item
<form></form>
used to make a web form.
<table></table>
used to make a table in a web page.

More HTML tags (Inline tags)

Entities in HTML and XHTML

Introduction to Tables

Example:

<style>
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
</style>
<table>
    <caption>grade table</caption>
    <tr><th></th><th>Item</th><th>Value</th></tr>
    <tr><th>1.</th><td>Homeworks</td><td>50%</td></tr>
    <tr><th>2.</th><td>Exams</td><td>50%</td></tr>
</table>
grade table
ItemValue
1.Homeworks50%
2.Exams50%

More on Tables

You can make table headings or table data span more than one column or more than one row using colspan, rowspan:

<tr><th colspan="3">heading</th></tr>


<!-- if we have two levels of heading-->

<tr><th colspan="2">heading</th></tr>
<tr><th>subhead1</th><th>subhead2</th></tr>
<tr><td>1</td><td>2</td><td</tr>

An Accessibility Interlude

Tables and Accessibility

Controlling width

Still More on Tables

Cellpadding, cellspacing

Forms

Possible methods

Labels and Controls

select tags

<textarea>