---
# System prepended metadata

title: 'Section 6: Basic HTML data types'
tags: [HTML4 SPEC]

---

---
tags: HTML4 SPEC
---
# Section 6: Basic HTML data types
[link](https://www.w3.org/TR/html401/types.html)

> basic data types that may appear as an element's content or an attribute's value.

## 6.1 Case information

Each attribute definition includes information about the case-sensitivity of its values. The case information is presented with the following keys:
- CS
     The value is case-sensitive (i.e., user agents interpret "a" and "A" differently).
- CI
    The value is case-insensitive (i.e., user agents interpret "a" and "A" as the same).
- CN
    The value is not subject to case changes, e.g., because it is a number or a character from the document character set.
- CA
    The element or attribute definition itself gives case information.
- CT
    Consult the type definition for details about case-sensitivity.
    
> If an attribute value is a list, the keys apply to every value in the list, unless otherwise indicated.


## 6.2 SGML basic types

The document type definition specifies the syntax of HTML element content and attribute values using SGML tokens (e.g., PCDATA, CDATA, NAME, ID, etc.).
The following is a summary of key information:
- CDATA (character data)
    - a sequence of characters from the document character set. User agents should interpret attribute values as follows:
        - Replace character entities with characters
        - Ignore line feeds(換行)
        - Replace each carriage return(回車) or tab with a single space.
    - User agents may ignore leading and trailing white space in CDATA attribute values (e.g., "   myval  " may be interpreted as "myval"). Authors should not declare attribute values with leading or trailing white space.
    - Although the STYLE and SCRIPT elements use CDATA for their data model, for these elements, CDATA must be handled differently by user agents. Markup and entities must be treated as raw text and passed to the application as is. The first occurrence of the character sequence "</" (end-tag open delimiter) is treated as terminating the end of the element's content. In valid documents, this would be the end tag for the element.
    - (entity: 用字元去表示特殊符號)
- ID and NAME
    - tokens must begin with a letter ([A-Za-z])
    - may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
- IDREF(single token) and IDREFS(a space-separated list of tokens)
    - references to ID tokens defined by other attributes
- NUMBER
    - tokens must contain at least one digit ([0-9]).

## 6.3 Text strings
A number of attributes ( %Text; in the DTD) take text that is meant to be "human readable".

## 6.4 URIs
- Note that URIs include URLs
- URIs are represented in the DTD by the parameter entity [%URI;](https://www.w3.org/TR/html401/sgml/dtd.html#URI)
- URIs in general are case-sensitive.
**[Note] **
    * URI-> URL+URN
    * URL->一個function(多對一或一對一)  
    * URN -> 一種maping，
## 6.5 Colors
- The attribute value type "color" (%Color;) refers to color definitions as specified in [SRGB].
- hexadecimal number or one of the following sixteen color names.
    ![](https://i.imgur.com/xnDeYwm.png)

#### 6.5.1 Notes on using colors
- The use of HTML elements and attributes for specifying color is [deprecated](https://www.w3.org/TR/html401/conform.html#deprecated). You are encouraged to use [style sheets](https://www.w3.org/TR/html401/present/styles.html) instead.
- Don't use color combinations that cause problems for people with color blindness in its various forms.
- If you use a background image or set the background color, then be sure to set the various text colors as well.
- Colors specified with the [BODY](https://www.w3.org/TR/html401/struct/global.html#edef-BODY) and [FONT](https://www.w3.org/TR/html401/present/graphics.html#edef-FONT) elements and [bgcolor](https://www.w3.org/TR/html401/present/graphics.html#adef-bgcolor) on tables look different on different platforms (e.g., workstations, Macs, Windows, and LCD panels vs. CRTs). In the future, support for the [[SRGB]](https://www.w3.org/TR/html401/references.html#ref-SRGB) color model together with [ICC color profiles](https://zh.wikipedia.org/wiki/ICC%E8%89%B2%E5%BD%A9%E7%89%B9%E6%80%A7%E6%96%87%E4%BB%B6) should mitigate this problem.
- When practical, adopt common conventions to minimize user confusion.

## 6.6 Lengths

HTML specifies three types of length values for attributes:
1. **Pixels** ([%Pixels;](https://www.w3.org/TR/html401/sgml/dtd.html#Pixels) in the DTD)
    integer that represents the number of pixels of the canvas (screen, paper).
2. **Length** ([%Length;](https://www.w3.org/TR/html401/sgml/dtd.html#Length) in the DTD)
    
    may be either a %Pixel; or a percentage of the available horizontal or vertical space. Thus, the value "50%" means half of the available space.
    
3. **MultiLength** ( [%MultiLength;](https://www.w3.org/TR/html401/sgml/dtd.html#MultiLength) in the DTD)
    
    may be a %Length; or a relative length.
    
    A relative length has the form "i*", where "i" is an integer.
    
    user agents allot pixel and percentage lengths first, then divide up remaining available space among relative lengths.
    
    ex. 
    
    if 60 pixels of space are available after the user agent allots pixel and percentage space, and the competing relative lengths are 1*, 2*, and 3*, the 1* will be alloted 10 pixels, the 2* will be alloted 20 pixels, and the 3* will be alloted 30 pixels.
    
- Length values are [case-neutral.](https://www.w3.org/TR/html401/types.html#case-neutral)

## 6.7 Content types (MIME types)

- This type is represented in the DTD by [%ContentType;.](https://www.w3.org/TR/html401/sgml/dtd.html#ContentType)
- [case-insensitive.](https://www.w3.org/TR/html401/types.html#case-insensitive)
- Examples of content types include "text/html", "image/png", "image/gif", "video/mpeg", "text/css", and "audio/basic".！
- registered content types (MIME types)

## 6.8 Language codes
- specified by [[RFC1766]](https://www.w3.org/TR/html401/references.html#ref-RFC1766), section 2.

- For information on specifying language codes in HTML, please consult the section on [language codes](https://www.w3.org/TR/html401/struct/dirlang.html#langcodes).

- Language codes are [case-insensitive.](https://www.w3.org/TR/html401/types.html#case-insensitive)

## 6.9 Character encodings
- The "charset" attributes (%Charset in the DTD) refer to a character encoding as described in the section on character encodings.
- Values must be strings (e.g., "euc-jp") from the IANA(Internet Assigned Numbers Authority) registry (see [CHARSETS] for a complete list).
- Names of character encodings are case-insensitive.
[Note]
Language codes -> 指內容是什麼用語言
Character encodings -> 指這個語言要用什麼編碼方式
## 6.10 Single characters
- Certain attributes call for a single character from the document character set. These attributes take the %Character type in the DTD.
- Single characters may be specified with [character references](https://www.w3.org/TR/html401/charset.html#entities)

## 6.11 Dates and times
- The format is:
    YYYY-MM-DDThh:mm:ssTZD
- where:
    YYYY = four-digit year
    MM   = two-digit month (01=January, etc.)
     DD   = two-digit day of month (01 through 31)
     hh   = two digits of hour (00 through 23) (am/pm NOT allowed)
     mm   = two digits of minute (00 through 59)
     ss   = two digits of second (00 through 59)
     TZD  = time zone designator

- **The time zone designator**
    - Z 
        indicates UTC (Coordinated Universal Time). The "Z" must be uppercase.
    - +hh:mm
        indicates that the time is a local time which is hh hours and mm minutes ahead of UTC.
    - -hh:mm
         indicates that the time is a local time which is hh hours and mm minutes behind UTC.


 ## 6.12 Link types
 Authors may use the following recognized link types, listed here with their conventional interpretations.
 These link types are case-insensitive.
 
 - **Alternate**
    - Designates substitute versions for the document in which the link occurs.
    - [lang](https://www.w3.org/TR/html401/struct/dirlang.html#adef-lang) attribute: implies a translated version of the document.
    - [media](https://www.w3.org/TR/html401/present/styles.html#adef-media) attribute: implies a version designed for a different medium (or media).
- **Stylesheet**
    - Refers to an external style sheet.
    - This is used together with the link type "Alternate" for user-selectable alternate style sheets.
- **Start**
    - Refers to the first document in a collection of documents.
- **Next**
    - Refers to the next document in a linear sequence of documents.
- **Prev**
    - Refers to the previous document in an ordered series of documents.
- **Contents**
    - Refers to a document serving as a table of contents. (目錄)
- **Index**
    - Refers to a document providing an index for the current document. (like 原文書後面的index，
- **Glossary(詞彙表)**
    - Refers to a document providing a glossary of terms that pertain to the current document.
- **Copyright**
    - Refers to a copyright statement for the current document.
- **Chapter**
    - Refers to a document serving as a chapter in a collection of documents.
- **Section**
    - Refers to a document serving as a section in a collection of documents.
- **Subsection**
    - Refers to a document serving as a subsection in a collection of documents.
- **Appendix**
    - Refers to a document serving as an appendix in a collection of documents.
- **Help**
    - Refers to a document offering help (more information, links to other sources information, etc.)
- **Bookmark**
    - Refers to a bookmark.
    - A bookmark is a link to a key entry point within an extended document. The [title](https://www.w3.org/TR/html401/struct/global.html#adef-title) attribute may be used, for example, to label the bookmark. Note that several bookmarks may be defined in each document.

## 6.13 Media descriptors
The following is a list of recognized media descriptors
 ( %MediaDesc in the DTD).
 - **screen**
    - Intended for non-paged computer screens.
- **tty**
    - Intended for media using a fixed-pitch(固定間距) character grid, such as teletypes, terminals, or portable devices with limited display capabilities.
- **tv**
    - Intended for television-type devices (low resolution, color, limited scrollability).
- **projection**
    - Intended for projectors.
- **handheld**
    - Intended for handheld devices (small screen, monochrome, bitmapped graphics, limited bandwidth).
- **print**
    - Intended for paged, opaque material and for documents viewed on screen in print preview mode.
- **braille**
    - Intended for braille tactile(觸覺) feedback devices.
- **aural**
    - Intended for speech synthesizers.
- **all**
    - Suitable for all devices.

## 6.14 Script data
- Script data ( [%Script;](https://www.w3.org/TR/html401/sgml/dtd.html#Script) in the [DTD](https://www.w3.org/TR/html401/sgml/dtd.html)) can be the content of the [SCRIPT](https://www.w3.org/TR/html401/interact/scripts.html#edef-SCRIPT) element and the value of [intrinsic event attributes](https://www.w3.org/TR/html401/interact/scripts.html#scripts).
- User agents must not evaluate script data as HTML markup but instead must pass it on as data to a script engine.
- The case-sensitivity of script data depends on the scripting language.

## 6.15 Style sheet data
- Style sheet data ([%StyleSheet;](https://www.w3.org/TR/html401/sgml/dtd.html#StyleSheet) in the [DTD](https://www.w3.org/TR/html401/sgml/dtd.html)) can be the content of the [STYLE](https://www.w3.org/TR/html401/present/styles.html#edef-STYLE) element and the value of the [style](https://www.w3.org/TR/html401/present/styles.html#adef-style) attribute. User agents must not evaluate style data as HTML markup.
- The case-sensitivity of style data depends on the style sheet language.

## 6.16 Frame target names
The following target names are reserved and have special meanings.

- **_blank**
    The user agent should load the designated document in a new, unnamed window.
- **_self**
    The user agent should load the document in the same frame as the element that refers to this target.
- **_parent**
    The user agent should load the document into the immediate [FRAMESET](https://www.w3.org/TR/html401/present/frames.html#edef-FRAMESET) parent of the current frame. This value is equivalent to _self if the current frame has no parent.
    
- **_top**
    The user agent should load the document into the full, original window (thus canceling all other frames). This value is equivalent to _self if the current frame has no parent.