Let's talk about block elements first. Elements in HTML can be divided into block and inline elements. The default display attribute of block elements is block, and the default display attribute of inline elements is inline. inline elements include:
A, abbr, acronym, B, BDO, big, BR, button, cite, code, dfn, Em, I, IMG, input, KBD, label, MAP, object, Q, SAMP, script, select, small, span, strike, strong, sub, sup, textarea, TT, VAR
Basefont, Font, S, U
Block elements include Address, BLOCKQUOTE, Div, DL, fieldset, form, h1-h6, HR, noframes, NoScript, ol, P, pre, table, UL center, Dir, isindex, menu.
By default, block elements occupy the position of one row, and the next element is forced to appear in the Next row. This is not the case for inline elements. inline elements make the next element automatically pasted to its own edge display, such as span and textbox...
Some inline elements are displayed as block elements for some design purposes. For example, element. After the element is displayed: block, it becomes a block element from the inline element, and then you can set attributes such as margin, padding, and border for this element. Refer to the design of this navigation bar:
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312"/>
<Style>
# Nav {
}
# Nav Li {
Float: left;
}
# Nav Li {
Color: #000000;
Text-Decoration: none;
Padding-top: 4px;
Display: block;
Width: 97px;
Height: 22px;
Text-align: center;
Background-color: # ececec;
Margin-left: 2px;
}
</Style>
</Head>
<Body>
<Ul id = "nav">
<Li> <a href = "#"> first page </a> </LI>
<Li> <a href = "#"> chapter </a> </LI>
<Li> <a href = "#"> Participation </a> </LI>
<Li> <a href = "#"> blog </a> </LI>
<Li> <a href = "#"> discussion </a> </LI>
<Li> <a href = "#"> contact </a> </LI>
</Ul>
</Body>
</Html>