A good HTML skeleton

前端 未结 6 1926
独厮守ぢ
独厮守ぢ 2021-01-31 08:15

I want to start creating websites again, but I\'ve been out of the HTML scene for a while now. I was just wondering if this is a good skeleton for a website. And if not, what sh

6条回答
  •  忘了有多久
    2021-01-31 08:27

    tl;dr

    
    
    
      
      Example
      
      
      
      
    
    
    
      

    Example


    An HTML5 skeleton could look like this:

    
    
    
      
      CC
    
    
    
    
    
    

    (Note that this is not the most minimal HTML5 document, so many parts are optional.)

    If you are using a different encoding than UTF-8, change the value of the meta-charset accordingly.

    If you are using a different content language than English, change the value of the lang attribute accordingly.

    If you want to explicitly specify the text directionality, use the dir attribute on the html element, e.g.:

    Common link/meta elements to add to the head

    • Linking to a stylesheet (text/css is assumed by default):

      
      
    • Linking to a favicon:

      
      
    • Specifying the canonical URL of the document:

      
      
    • Providing a description of the page’s content:

      
      

    Elements for the body

    As each page is different, this can‘t be answered generally, so it might be best to leave the body empty.

    However, most pages probably are part of a website, and most websites probably have a site-wide header (→ header) with site name (→ h1), footer (→ footer) and navigation menu (→ nav). These should belong to the body sectioning root (i.e., have no other sectioning content element as parent). The nav may or may not be part of the header.
    The main content (→ main) may or may not consist of a sectioning element (usually article or section, or multiple of them).

    Example

提交回复
热议问题