Kinds of Tags


Not all CSS definitions can be applied to all HTML or XHTML tags. Whether a particular CSS property can be applied (or not) depends on the nature of the tag. For the most part, it's fairly obvious if the property can be applied.

For example, you wouldn't expect the text-indent property, which indents the first line of a paragraph, to apply to an inline tag such as <b>, and it can't be. If you do find you need some help in this area, see this book's companion Web site (webbedenvironments.com/css_dhtml_ajax) for a list of the properties that can be used with a particular kind of HTML or XHTML tag.

HTML and XHTML tags can generally be sorted into three categories:

  • Block-level tags place a line break before and after the element. Table 1.2 lists the block-level tag selectors that CSS can use.

    Table 1.2. Selectors for Block-Level Tags

    SELECTOR

    HTML USE

    blockquote

    Quote style

    br

    Line break

    center

    Center text

    dd

    Definition description

    div

    Division

    dl

    Definition list

    dt

    Definition term

    h1-6

    Heading levels 1-6

    li

    List item

    object

    Object embedding

    ol

    Ordered list

    p

    Paragraph

    pre

    Preformatted text

    table

    Table

    td

    Table data

    th

    Table head

    tr

    Table row

    ul

    Unordered list


  • Inline tags have no line breaks associated with the element. Table 1.3 lists the inline-tag selectors that CSS can use.

    Table 1.3. Selectors for Inline Tags

    SELECTOR

    HTML USE

    a

    Anchored link

    b

    Bold

    big

    Bigger text

    cite

    Short citation

    code

    Code font

    dfn

    Defined term

    em

    Emphasis

    font

    Font appearance

    i

    Italic

    img

    Image embedding

    span

    Localized style formatting

    strike

    Strikethrough

    strong

    Strong emphasis

    sub

    Subscript

    sup

    Superscript

    tt

    Teletype font

    u

    Underlined text

    input

    Form input object

    select

    Form select input area

    textarea

    Form text input area


Tips

  • Some coders just slap the <p> tag into their code to start a new paragraph tag without its closing </p>. The closing tag must be included if you want to define paragraphs using CSS.

  • Although the break tag (<br>) does not have a closing tag, you can add styles to it. However, remember that in XHTML, the break tag becomes <br /> (with a space between the br and the /) so that it is self-closing.





CSS, DHTML and Ajax. Visual QuickStart Guide
CSS, DHTML, and Ajax, Fourth Edition
ISBN: 032144325X
EAN: 2147483647
Year: 2006
Pages: 230

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net