html5 - Single CSS Stylesheet, or one stylesheet per section? -
i working on website (or rather few websites) done in html5/css3 bit of php thrown in there few functions.
so proper practice having css in single stylesheet called page or (because of shear size of code) having each section have own external style sheet? (between nav bar , footer alone 1500-2000 lines of code.)
there benefits , fall backs either such code cleanliness , amount of "calls" more 1 style sheet. there solid technical reasons why 1 use more other? goal make best possible website smallest foot print fast , accessed various devices. it's not user intensive or process heavy.
regarding tag capitalization, little history may in understanding why trend has shifted uppercase lowercase: in html4 elements typically written in uppercase, according w3schools, w3c recommended written in lowercase (although can't find reference). then, xhtml became popular; the specification stipulated elements , attributes must lowercase. , html5 specification says can go either way, lowercase recommended.
regarding internal , external css, depends. if multiple pages accessing same css, then browser cache it, meaning wise put css separate file. code abstraction too. however, if single page, may choose go inline.
regarding navigation bar, matter of preference. load template file, run through dom, , insert elements need. performance may choose go method, code abstraction.
something following:
<?php class webpage { private $document; function __construct() { $this->document = new domdocument(); if($this->document->loadhtmlfile("template.html")){ $this->createheadermenu(); }else{ trigger_error("webpage->__construct() failed load template.html", log_err); } } protected function createheadermenu() { $headermenu = $this->document->getelementbyid("header-menu"); $li = $this->document->createelement("li"); $a = $this->document->createelement("a", "homepage"); $a->setattribute("href", "/"); $a->setattribute("target", "_self"); $a->setattribute("title", "homepage"); $li->appendchild($a); $headermenu->appendchild($li); } public function output() { return (string) $this->document->savehtml(); } } $page = new webpage(); echo($page->output()); ?> of course, template.html template, , there need ul element in there id attribute set header-menu.
Comments
Post a Comment