Are there any CSS standards that I should follow while writing my first stylesheet?

前端 未结 17 634
有刺的猬
有刺的猬 2020-12-13 02:40

I am currently working on my first website. I have no idea where to start on the CSS page, or if there are any standards that I should be following.

I would appreci

17条回答
  •  眼角桃花
    2020-12-13 03:30

    Resist the urge to over-specify class or id names. Use contextual or descendent selectors. This let's you easily define styles for areas of your page, but save on the sanity of having to manage and remember tons of names. For example:

    
    
    #nav { }
    #nav .navItem { }
    #nav .itemText { }
    

    This is needlessly complex, and you'll find yourself quickly running out of good semantic descriptions. You'd be better off with something like:

    
    
    #nav {}
    #nav li {}
    #nav li span {}
    

提交回复
热议问题