CSS中的ID和class

  本来以为它们两个是没什么太大区别的,但是今天上网上一查,发现还是有些区别的。最主要的大概就是在CSS定义中,ID是以#开头的,而class是以.开头的。而且在网页编程中,一个ID只能出现一次,就像某个东西的标识符一样,在一个页面中,只能有一个,而class是可以出现多次的。看了一篇文章说,id是先找到结构或内容,再套用样式,而class是先定义好样式,再应用到多个结构或内容上,呵呵,还真有点这么回事 :)

This entry was posted in Happy coding. Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>