Common CSS and HTML usage errors

Source: Internet
Author: User

myth one. Multiple div syndrome

<div class= "NAV" >    <ul>       <li><a href= "/home/" >Home</a></li>       <li ><a href= "/about/" >About</a></li>       <li><a href= "/concact/" >Concact</a> </li>    </ul></div>

Simplified into the following

<ul class= "NAV" >       <li><a href= "/home/" >Home</a></li>       <li><a href= "/ about/">About</a></li>       <li><a href="/concact/">Concact</a></li> </ Ul>

Myth Ii. Multi-class class Syndrome note class can be applied to any number of elements of a page, and is ideal for identifying content types or other similar entries

A piece of news (news headlines, news details) class News-head and News-text multi-class manifestations, do not require so many classes to differentiate element styles

<H1 class= "News-head" >elastic Layout example-view Source for the HTML and css

It is best to use Div (division) to represent part rather than without semantics (most people misunderstand div without semantics!!!) ), You can divide the document into several meaningful areas, the class name news, to identify the entire news item.

You can then use the cascading (Cascade) style to identify news headlines, text

<div class= "News" >

span groups or identifies inline elements

myth three. ID usage myths Identify specific elements on a page (such as site navigation, headers, footers) and must be unique, and can be used to identify persistent structural elements such as main navigation, content area

/* Large number of Use IDs, difficult to find unique name confusion */#andy, #rich, #jeremy, #james-box, #sophie {font-size:1em;font-weight:bold;border:1px solid # CCC;} /* Simply replace it with a common class */.staff {font-size:1em;font-weight:bold;border:1px solid #ccc;}

Used to identify specific elements on a page (such as site navigation, headers, footers) and must be unique; can also be used to identify persistent structural elements (such as main navigation, content area)

Common CSS and HTML usage errors

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.