ucsb / webguide

Repository for the UCSB WSG Webguide hosted on Github using Jekyll.
https://webguide.ucsb.edu
BSD 3-Clause "New" or "Revised" License
7 stars 7 forks source link

Migrate "Header" Page #400

Closed loganfranken closed 3 years ago

loganfranken commented 3 years ago

384

Legacy Page https://webguide.ucsb.edu/header/

Location in New Hierarchy https://dev-webguide-ucsb-edu-v01.pantheonsite.io/development/html

It looks like all of this content is still relevant and could be moved into the new "HTML" section. It might make sense to remove explicit mentions of HTML5 since it's obvious now.


All of your HTML documents should begin with the following standardized set of elements in the header:

Doctype

A document's doctype determines which "rendering mode" will be used to display the document. The first line of your HTML document should be the HTML5 doctype declaration:

<!DOCTYPE html>

Using the HTML5 doctype does not mean that you must also use HTML5 elements within your document. This doctype is "backwards-compatible" with older HTML and XHTML syntax.

Document Language

Directly after the doctype declaration, include the opening html tag with the lang attribute set to the language of the document, along with the opening head tag:

<html lang="en">
<head>

Setting the document language can have a number of benefits, including assisting search engines and screen readers. For languages other than English, view the full list of language codes.

Character Encoding

The meta element specifiying the character encoding should be added directly after the opening head tag:

<meta charset="utf-8">

The character encoding meta element is inserted early in the document because the HTML5 specification explains that the meta tag should appear in the first 1024 bytes of the document.

Although the character encoding meta element should be included regardless, the character encoding should also be specified via server-side headers:

Content-Type: text/html; charset=utf-8

Also be sure your text editor is set to UTF-8.

UTF-8 is the only recommended character encoding for web pages.

Document Title

Next, add the title element:

<title>Document Title - Site Name</title>

The title should be short and descriptive. Put the most salient part of the title first. For example, use "Faculty : Department of Gaucho Studies" rather than "Department of Gaucho Studies : Faculty," so that the most distinguishing part of the title ("Faculty") will be visible to the user.

Document Description

The description meta element is often used by search engines to describe your document:

<meta name="description" content="The UCSB News Page features the
latest news and press releases from the University of California,
Santa Barbara.">

CSS Stylesheets

Next, include your CSS stylesheets:

<link href="css/main.css" rel="stylesheet">

No JavaScript Stylesheet

You may also want to include a stylesheet targeting users without JavaScript enabled:

<noscript>
  <link href="css/noscript.css" rel="stylesheet">
</noscript>

In general a user should be able to interact with a document without JavaScript; JavaScript should merely progressively enhance the experience.

Header Example

The following example summarizes the above suggestions:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">

    <title>Document Title - Site Name</title>

    <meta name="description" content="Description of document">

    <link href="css/main.css" rel="stylesheet">

    <noscript>
      <link href="css/noscript.css" rel="stylesheet">
    </noscript>
</head>
<body>
loganfranken commented 3 years ago

Migrated the content: https://dev-webguide-ucsb-edu-v01.pantheonsite.io/development/html