开发者

How to reduce the uses of CSS IDs and Classes in mark-up using HTML5 and CSS3?

开发者 https://www.devze.com 2023-03-07 09:04 出处:网络
How to reduce the uses of CSS IDs and Classes in mark-up using HTML5 and CSS3? Which HTML5 开发者_开发技巧tags and CSS3 properties can reduce the need of classes and IDs

How to reduce the uses of CSS IDs and Classes in mark-up using HTML5 and CSS3?

Which HTML5 开发者_开发技巧tags and CSS3 properties can reduce the need of classes and IDs

Currently I know

       <header>
        <nav>
        <section>
        <article>
        <aside>
        <footer>
    <time>
    <figure>
    <dialog>
    <mark>
<figcaption>
<hgroup>


The way these reference neighbors could be considered using less ids, and the html 5 tags with colons. This came from the Mix 11 videos.

CSS pop up menu:

.menu > li > ul {display: none;}
.menu > li:hover > ul { display:block;}

Dependent content:

.faq > div {display:none;}
.faq > div:target {display:block;}

Validation:

:valid, :invalid, :required, :optional, :in-range, :out-of-range, 
:read-only, :read-write

#signup input:focus:required:valid + .val .invalid {display:none;}
#signup input:focus:required:invalid + .val .valid {display:none;}

Animations:

.faq > div {display:none;}
.faq > div:target {display:block;position:relative;
       -webkit-animation:throb 1.5s infinite;}


Pseudo classes can do that, such as :first-child and :last-child, the latter which is new in CSS3.

You are better off having a look here.

0

精彩评论

暂无评论...
验证码 换一张
取 消