Styling

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Div tags[edit | edit source]

Syntax[edit | edit source]

<div style="border:1px solid black; margin-right:2em;">
Text
</div>

Notes[edit | edit source]

  1. Can be used inside another div tag
  2. Creates a new line

Span tags[edit | edit source]

Syntax[edit | edit source]

<span class="" style="color:red;">
Text
</span>

Notes[edit | edit source]

  1. Can be used inside div and other span tags
  2. Does not support some styles, including width, hight, and float

Inline styles[edit | edit source]

Syntax[edit | edit source]

style="color:red;"

Works for pretty much every tag as well for wikitables. What rules it uses (div or span) depends on the tag. Tables generally use the

rules, for example.

Classes[edit | edit source]

  • plainlinks (Removes the icon after external links)

Styles[edit | edit source]

  • font-size: 100%
  • color: black (text color)
  • text-align: left (set the text's align. Can be: left, right or center)
  • float: none (Makes it float, allowing there to be two columns of text going down. Can be left, right, or none)
  • background-color: none (can be any HTML color)
  • border: 0px solid black
  • margin: 0 0 0 0em (Adds a margin on the outside.) Also:
    • margin-left
    • margin-right
    • margin-top
    • margin-bottom
    • Simmilar in style:
      • padding: 0 0 0 0em (Adds space inside it.)
  • width: 100%
  • display: block (inline shows it on the same line. block shows it on a new line. none hides it)
  • position: (reletive allows it to move while keeping it in the same place. fixed shows it at the top of the screen. absolute is the same as "relative" but moves content to take up the space the object used to use)
    • Can be moved with:
      • top: 0px (positive numbers move it downward, negative numbers upward)
      • left: 0px (positive numbers move it right, negative numbers left)
      • bottom and right are also supported and give the opposite to top and left respectively
  • width (sets the width. See measurements)
  • min-width (sets a minimum width, but may grow in size to use available space)
  • height (sets the height)

Measurements[edit | edit source]

  • 0px (pixels)
  • 0em
  • 0% (percentage of fillable space)