“CSS is simple... It’s simple to understand. But CSS is not simple to use or maintain.” ʮCSS୯७Ͱཧղ͍͕͢͠ɺͬͨΓϝϯς ͨ͠Γ͢ΔͷγϯϓϧͰͳ͍ɻʯ http://chriseppstein.github.io/blog/2009/09/20/why-stylesheet-abstraction-matters/ -Chris Eppstein
“We have been doing it all wrong.... Our (CSS) best practices are killing us” ʮCSSͷϕετϓϥΫςΟεʹΑͬͯࢲୡμϝ ʹ͞Ε͍ͯΔɻʯ http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/ -Nicole Sullivan
Three Best Practice Myths ❖ Don’t add any extra elements ❖ Don’t add classes ❖ Use descendent selectors exclusively http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/
“CODE IS TOO FRAGILE.” http://www.stubbornella.org/content/2009/02/12/css-doesn’t-suck-you’re-just-doing-it-wrong/ -Nicole Sullivan ʮίʔυʢɿ͜͜ͰCSSʣΖ͗͢ʯ
“CSS isn't just visual design. Don't throw out programming best practices just because you're writing CSS. Concepts like OOP, DRY, the open/closed principle, separation of concerns, etc. still apply to CSS.” ʮΦϒδΣΫτࢤɺDRYɺ։์/ดݪଇɺؔ ৺ͷͳͲͷ֓೦ɺCSSʹͳ͓ద༻͞Ε Δɻʯ http://philipwalton.com/articles/css-architecture/
“abstract the structure of the block from skin which is being applied. Class can be extended by adding additional classes to the block element.” ʮεΩϯ͔ΒϒϩοΫߏΛநग़͢Δɻ ϒϩοΫཁૉผͷΫϥεΛ͚Ճ͑ΔࣄͰ Ϋϥε֦ுͰ͖Δɻʯ Separate Structure and Skin
“break the dependency between the container module and the content objects it contains.” ʮ ίϯςφʔϞδϡʔϧͱͦͷதͰ͋Δίϯ ςϯπͱͷґଘؔΛஅͪΔʯ Separate Container and Content
Three Best Practice Myths ❖ Don’t add any extra elements ❖ Don’t add classes ❖ Use descendent selectors exclusively http://www.stubbornella.org/content/2011/04/28/our-best-practices-are-killing-us/
“ ... not all semantics need to be content- derived ” ʮશͯͷηϚϯςΟΫε͕ίϯςϯπ༝དྷͰ͋ Δඞཁͳ͍ʯ http://nicolasgallagher.com/about-html-semantics-front-end-architecture/
“ Content-layer semantics are already served by HTML elements and other attributes. ” ʮίϯςϯπϨΠϠʔͷηϚϯςΟΫεɺ HTMLཁૉͱͦͷଞଐੑʹΑͬͯɺ͢Ͱʹ༩͑ ΒΕ͍ͯΔʯ http://nicolasgallagher.com/about-html-semantics-front-end-architecture/
“ Class names impart little or no useful semantic information to machines or human visitors... ” ʮΫϥε໊ɺαΠτӾཡऀϚγʔϯʹͱͬ ͯຆͲӨڹΛ༩͑Δ͜ͱͳ͘ɺ༗ӹͳใΛ ͨΒ͢͜ͱͳ͍ʯ http://nicolasgallagher.com/about-html-semantics-front-end-architecture/
“ The primary purpose of a class name is to be a hook for CSS and JavaScript. ” ʮΫϥε໊ͷୈҰͷతɺCSSJavaScriptͷ ϑοΫʹͳΔ͜ͱɻʯ http://nicolasgallagher.com/about-html-semantics-front-end-architecture/
“ Class names should communicate useful information to developers. ” http://nicolasgallagher.com/about-html-semantics-front-end-architecture/ ʮΫϥε໊։ൃऀ༗ӹͳใΛୡ͖͢ɻʯ
“ A flexible and reusable component is one which neither relies on existing within a certain part of the DOM tree, nor requires the use of specific element types. ” http://nicolasgallagher.com/about-html-semantics-front-end-architecture/ ʮϑϨΩγϒϧͰ࠷ར༻Մೳͳίϯϙʔωϯτ ɺDOMπϦʔͷ͋Δ෦ʹґଘ͢Δ͜ͱɺ ಛఆͷཁૉλΠϓΛ༻ͨ͠Γ͠ͳ͍ɻʯ
Do you need a CSS Architecture & Methodology like OOCSS ? ❖ How many developers ? ❖ Reuse ? ❖ Maintainance ? ❖ Scale ? http://philipwalton.com/articles/css-architecture/