Lecture 7: Inline Elements

Overview:

  1. Inline Elements
  2. Emphasizing Text
  3. Increasing / Decreasing Text Size
  4. Quotes and Citations
  5. Code, Variables, and Sample Output
  6. Spanning Text
  7. Subscripts and Superscripts
  8. Teletype Text
  9. Inserted and Deleted Text
  10. Acronyms and Abbreviations
  11. Definitions
  12. User Input
  13. Deprecated Inline Elements

Inline Elements

Emphasizing Text

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Emphasis in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p>Some text in this paragraph <strong>shows strong emphasis</strong>
    and other text is <em>just emphasized</em>.</p>
</body>
</html>

See how this example renders

Increasing / Decreasing Text Size

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Modifying Text Size in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p>Some text in this paragraph <big>is a bit larger</big>
    and other text is <small>a bit smaller</small>.</p>
</body>
</html>

See how this example renders

Quotes and Citations

Attribute Usage and Effect Values Accepted Default Deprecated?
cite Only used for <q> and not for <cite>. Contains the URL of the cited text. Text (usually a web address)   Not deprecated

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Inline citations and quotes in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p><cite>Jason Withrow</cite> has been known to say:
    <q>Separate structure and presentation in your code!</q></p>

    <p><cite>Jason</cite> also has quoted others:
    <q>My students usually say <q>Web design is fun!</q> and I agree.</q>
    </p>
</body>
</html>

See how this example renders

Code, Variables, and Sample Output

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Code, variables, and sample output in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p>The variable <var>x</var> was defined in this Javascript:</p>

    <code>var x = 'Hello World!';</code>

    <p>And so the result was:</p>

    <samp>Hello World!</samp>
</body>
</html>

See how this example renders

Spanning Text

Subscripts and Superscripts

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Subscripts and Superscripts in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p>The chemical composition was O<sub>2</sub> and<br />
    H<sub>2</sub>, as referenced in the research<sup>3</sup></p>
</body>
</html>

See how this example renders

Teletype Text

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Teletype Text in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p>The code for you to enter is: <tt>00343</tt></p>
</body>
</html>

See how this example renders

Inserted and Deleted Text

Attribute Usage and Effect Values Accepted Default Deprecated?
cite Contains the URL where the reason for the change is explained. Text (usually a web address)   Not deprecated
datetime The date and time the change was made. Date (such as YYYYMMDD)   Not deprecated

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Inserted and Deleted Text in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p>XHTML is used for
    <ins cite="http://www.w3.org/MarkUp/" datetime="20060515">structural</ins>
    <del datetime="20060515">presentational</del> markup.</p>
</body>
</html>

See how this example renders

Acronyms and Abbreviations

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Acronyms and Abbreviations in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p><acronym title="Washtenaw Community College">WCC</acronym>'s
    address is: 4800 <abbr title="East">E.</abbr> Huron River
    <abbr title="Drive">Dr.</abbr> <abbr title="Post Office">P.O.</abbr>
    Box D-1 Ann Arbor, <abbr title="Michigan">MI</abbr> 48106</p>
</body>
</html>

See how this example renders

Definitions

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Definitions in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p><dfn title="Cascading Style Sheets">CSS</dfn> stands
    for Cascading Style Sheets.</p>
</body>
</html>

See how this example renders

User Input

Sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>User input in (X)HTML</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <p>To proceed, enter <kbd>knock-knock</kbd></p>
</body>
</html>

See how this example renders

Deprecated Inline Elements

Element Usage and Effect Preferred Approaches
<font> </font> Still widely used to set the font in use (via the deprecated face attribute), text color (via the deprecated color attribute), and text size (via the deprecated size attribute). CSS is the ideal approach, applied to a non-presentational tag.
<basefont /> Specified inside of <head> </head> and used to set the font appearance for the entire page. Accepts the same deprecated attributes as <font>. CSS is the ideal approach.
<strike> </strike> Renders text with a line through it, at the midline of the character. CSS is the ideal approach; there is a property that handles this effect.
<s> </s> Renders text with a line through it, at the midline of the character. CSS is the ideal approach; there is a property that handles this effect.
<u> </u> Renders text with an underline. This presents major usability issues, because users expect underlined text to be a link. CSS is the ideal approach; there is a property that handles this effect.