The advanced layout of DIV + CSS has gradually become popular, but the so-called DIV + CSS layout makes people more worried. Do not make DIV a substitute for Table, the multi-layer nested DIV will seriously affect the readability of the code. Use the tags provided by HTML.
When should I use DIV?
Although there are no hard rules in this regard, I personally think that DIV is more suitable for positioning the general framework. For example, if we want to define a region of a header, a DIV is usually defined as follows:
<Div id = "header"> the content to be written in the header framework </div>
Of course, you can use class to define it, but generally, if it is not an element that will be repeated on the same page, it can be better differentiated by id.
View the following definition code:
The code is as follows: |
Copy code |
<Ul id = "navbar"> <Li id = "articles"> <A href = "/articles/" title = "Articles"> Articles </a> </li> <Li id = "topics"> <A href = "/topics/" title = "Topics"> Topics </a> </li> <Li id = "about"> <A href = "/about/" title = "About"> About </a> </li> <Li id = "contact"> <A href = "/contact/" title = "Contact"> Contact </a> </li> <Li id = "contribute"> <A href = "/contribute/" title = "Contribute"> Contribute </a> </li> <Li id = "feed"> <A href = "/feed/" title = "Feed"> Feed </a> </li> </Ul> <H1 id = "masthead"> <A href = "/">
</A> </H1> <Div id = "ish"> <A href = "/issues/214" title = "Issue 214"> No. <em> 214 </em> </a> </Div>
|
Defines the top navigation (ul part), the big logo on the left and the mark of the round No. xxxx.