Contribution to the stylistic guide for HTML and

Florent launches the project to write a stylistic guide (editorial guidelines or Conventions of coding) for languages HTML and especially under the aegis of . A description of this project is available in this document. Here my modest contribution to this first stage of the project which consists of two series of questions to probe the professionals of the web-based on their practices of work as regards working of the code.

How I write my HTML

  1. Which version of HTML or XHTML do you use?
    Even if I endeavor to write XHTML 1.0 strict, I use XHTML 1.0 who allows a certain flexibility when one works on documents likely to accommodate all kinds of ornaments like or you in here want some;)
  2. Do you comply with strict rules for the writing of the beacons and attributes HTML even in HTML 4.01?
    Yes, I conform to the imposed by the XHTML strict 1.0: writing of the beacons in small letters, attributes between quotation marks, attributes or doubled ( " " or " "), car-closing of the beacons , Br or input, etc
  3. Which use do you make validation of the HTML code?
    I take care to validate my Web pages regularly from a point of view of of the code rather than for the validation itself which does not guarantee that the document is readable by an human being.
  4. Which use made you of comments HTML?

    Primarily to emphasize the main parties of the page and to indicate the end of the structural blocks. I use also the blank lines to separate certain parties of the code to improve legibility:

    <! -- Beginning of #sidebar-signal
     for the form of log on contains 
    and  for the  -->
    
         " sidebar-signal "  "  " >
    
             " block-1 " >
                
            ! --  -->
    
             " block-2 " >
                
            ! --  -->   
    
        ! -- fine #sidebar-signal  -->
    
    <! -- // end of #sidebar-signal -->
    
    <! -- Beginning of 
     for the advertizing contains
    and  for the inscription with the  -->
    
  5. Which are the HTML elements which you use more? Is there a precise logic for the use of such or such element (a P rather than a , for example)?
    In rule general, I try to follow the internal logic of the contents so that the page resembles something even if the style sheets are decontaminated: I misuse the lists ordered or not, the lists of definition, the paragraphs, etc the idea is to give relief to the Web page to emphasize the structure of the ideas.
    However, it sometimes happens to me to use a in the place of a p when the text to be marked out contains only one line and/or that it is insulated semantically speaking. It is the case of the in particular.

    In certain cases, it can sometimes happen to me to add a :

     "  "  is 
    

    Favors it? In certain workings, that makes it possible to give a width clarifies with the beacon , while playing at will on the of the without breaking making up because of a bad interpretation of a model of does not limp always intuitive.

  6. Which use do you make generic elements and ?
    Even if that seems to go against my preceding answer, I start by structuring my page in the main lines with the position of the various “blocks” to the spirit. As it is often a question of cutting out a carried out under , he would be hypocritical to make as so only the direction had importance… I thus place my in my HTML document then I defer them in my file .
    The beacons are especially used to me to divide the contents into blocks managed then via the style sheet: creation of columns, implementation of background, etc I try to keep a “semantic” logic with my cuttings, even if most of the time, it is necessary well to acknowledge that certain block are joined together only at ends of presentation or position in the code…
    I use the beacon rather little: it is generally used to me to give a color different to a portion from text or to integrate the .
  7. Do you have a Convention of naming for the classes and identifiers?
    I am in full transition on this question. I gently put myself to use the future beacons of the as identifiers or classes to structure my Web pages: , , , , , , H2…, , etc
    For the identifiers or classes made up of two terms or more, I use the dash: #sidebar-signal or #main-content-bottom, for example.
    As you can notice it, I use Anglo-Saxon terms rather, generally more concise and especially without accent: what would give a class.palais-of-congers indeed
  8. In which cases rather do use you the classes or rather the identifiers?

    All depends on the document, but I privilege the classes as much as possible. Thus, to reach the small element, I use more readily:

     {…}
     {…}
    

    rather than:

         {…}
         {…}
    

    What makes it possible to have common elements not duplicated for the class . However, according to the projects, the second solution is sometimes preferable. Question of flexibility.

How I write my

  1. Which use do you make validation ?
    I use only very seldom the validation for my style sheets: the faults of syntaxes are generally crippling (the desired behavior does not appear) and I generally know when I use a property “owner”…
  2. How do you use the comments in ? Do you have precise “styles” for various types of comments (capitals, stars or other symbols in the comment, etc)?

    An example is better than a long discourse:

    /*-----------------------------------------------------------------------
    Name of the style sheet: 
    Date creation: the 11/2/2008
    Description: Main style sheet for project 
    Synopsis:
    @reset
    @utilitaires
    @document
    -----------------------------------------------------------------------*
    
    /*-----------------------------------------------------------------------
                                         @RESET
    -----------------------------------------------------------------------*
    
    @import “/”;
    
    /*-----------------------------------------------------------------------
                                        @UTILITAIRES
    -----------------------------------------------------------------------*
     {
        : , male;
    }
    
    /*-----------------------------------------------------------------------
                                        @DOCUMENT
    -----------------------------------------------------------------------*
     {
        : 0 louse;
    }
    
         {/*  *
            : 75px;
        }
             {
                background: URL (/) No-repeat;
            }
    
  3. Do you use the “” selectors (most precise possible and taking again the context of use of the element), or on the contrary shortest possible? Or an intermediate solution?

    When I am not the only one to intervene on the project (most of the time) I am enough “wordy”:

     {…} 
    

    or

         {…} 
    

    Even

         {…}
    

    rather than

         {…}
    

    Note: for questions of performance, it is preferable to use the form #h1-logo {…} who seems the preferred syntax of the navigators.

  4. How do you use spaces, returns to the line, blank lines and indentations? Can you provide a typical example?

    Here an example rather representative of my practices on the matter:

     {
        : 950px;
        : 0 car;
        make: 1.2em/1.5 , Arial, without-serif;
    }
    
         {
            : 950px;
            : 95px;
            background: transparency URL  No-repeat ;
        }
    
        #main-content {
            : ; /* zoom: 1; in  *            
        }
             {
                : left;
                : 700px;
                : 20px;
            }
             {
                : left;
                : 230px;
            }
    
         {
            : 950px;
            : ;      
        }
    

    I took the practice to put a space between the colons and the value for reasons of legibility. In addition, I always leave the semicolon to the end of the last statement. Many integrators and developers find more readable to write:

     {: left; : 700px; : 20px;}
     {: left; : 230px;}
    

    Their main argument is that this provision makes it possible to see more selectors and to save lines. I make a point of recalling that many softwares (Dreamweaver, Light, etc) have such a sight. Without counting services as which do it automatically!

  5. Do you gather the blocks of statements (selector + their properties) in a logical or foreseeable way? Which is logic used, and in which order you place them?

    I try to follow as well as possible the structure of the HTML document itself. Like it the above example shows, except if I must gather statements to allot common properties to them. In this case, I place them as follows:

    ,
     {
        : 100%;
    }
    
     {
        : 3em;
    }
     {
        : 950px;
    }
     {
        : 1em 3em;
    }
    
  6. Do you use multiple indentations (up to several levels of indentation) for, for example, to reflect the structure of the HTML code?
    Yes, to see the example given higher;)
  7. Do you use the properties of short cut? If so, do you use them systematically and in priority, or only when that makes it possible to gain some statements (property + value)?
    I use the short cuts as often as possible, in particular for the properties make, background, , , list-style and to border.
  8. Do you adhere to a precise command for properties (alphabetical order, “logical” command, etc)? If need be, can you detail it?
    I place initially the properties more impacting on the design like , , , etc and I place then longest at the end: to border, list-style, make, background, etc
    Ca falls well, because these last are often properties more visual than structural, which makes it possible to separate the subgrade within statements !
  9. In a relatively long style sheet (more few tens of line, and to hundreds or thousands of lines), how organize you the various styles?
    If the number of page is weak but that style sheet is very long, I use the comments to separate the various parties.
    If the number of page is important, I make a style sheet by page after having joined together the common elements in , that is to say: for , for or 404.css for 404.php, etc
  10. You use several style sheets for a project of “small” site (less than ten page-type). Do you use several style sheets for more consequent projects? How you separate the various styles: by type of properties , type of page, etc?
    I tested several methods to become pragmatic: I make as well as possible according to the project, of the time and the number of people likely to intervene on the file. A cutting of the like , , , , etc supposes practices of joint work and similar knowledge in , which is not always the case when one works in team. In fact, cutting by page (cf answer 9) is often better understood thus waste of time and the errors are fewer.
  11. Do you use ?
    Yes and not. See low;)
  12. Do you use the conditional comments for Internet Explorer? If so, how do you proceed?

    In general, I use a conditional comment to target the versions lower than Internet Explorer 8:

    Then, inside , I use to target IE6 or :

     {to address itself to all the versions lower than }
    * HTML  {to address itself to IE6}        
     {to address itself to }
    

    By supposing of course that behaves in the future according to the standards of the web-based. In the contrary case, according to the cases, it will be necessary either to level the conditional comment ( IE 8) and to find a specific to different at the same time from IE6 and , or to link a specific style sheet for in addition to that planned for the lower versions of Internet Explorer…

In short

I took a real pleasure to lean me on these questions and as I would not like to be the only one to benefit from it, I invite you to take part in this project, than you are professional or enlightened amateurs! The important thing is that you practice regularly languages HTML and to have developed some practices and that you want to share them.

: , , , ,
Published on November 3rd, 2008 by Bruno .


Ca can interest you”


9 participations in the item

  1.  
    1 Yves spoke on November 3rd, 2008 with 09:35 |
     

    Cheer Bruno, beautiful item. Length and rich person… You confirm what I think, namely, much makes attention with validation HTML or , and little for the validation of the style sheets… I note your method of classification of the properties (point 8) which is not uninteresting…

  2. 2 Nicolas F. spoke on November 3rd, 2008 with 14:01 |
     

    ,

    I answered here: http://www.thinkxtreme.com/ It is amusing to see the similarities between the various professionals without prior cooperations.

    Just for point : 4, the reason for which I only go very little to the line, it is that after one ends up more not making but what is often the case in the case of a single style sheet for all the site.

  3.  
    3 Yves spoke on November 3rd, 2008 with 17:49 |
     

    For item 4 stressed by Nicolas, it is true that much does not make newlines. I believe that it is on (or I know more), In addition, that he advised to remain on the same line for each “block”. The file is thus largely less long, one not, it is true, but I find that it loses of legibility. I prefer and make like Bruno…

  4.  
    4 spoke on November 3rd, 2008 with 19:40 |
     

    Thank you for this item which I find very useful: I am always also fascinated by the play between HTML and and do not have the time of me to dive there. This kind of item forwards a work method which makes it possible to better understand what it turns over. … if I had time! one day perhaps….

    Just a small opinion of female user of style sheets there (always to go to bring my , sorry if one do-it-yourselfing your works): I clearly prefer the aired presentation, even if is needed. It is increasingly more comprehensible for us, poor amateurs.

  5. 5 spoke on November 4th, 2008 with 01:25 |
     

    Thank you for this item Ca allows to see how make the large ones considering I begin more or less. As for do the question of “I go to the line or not”, why not use (or if that still exists) to generate the version which the navigator will ask (without the passages to the line and spaces) and to keep the version “aired” for (S) the developer (S)? That regulates the performance problems and of legibility.

  6.  
    6 Florent V. spoke on November 4th, 2008 with 12:48 |
     

    Hello,

    The problems of the weight of the style sheets must be regulated indeed with a process of passage in production: leaves of development with the most readable possible code, abundantly commented on why not, and of the means automated (scripts) to obtain a version of production. One can also think of compression Gzip server side to reduce the weight of the files appreciably to be sent.

    In light: - If you work on small sites, you do not break the head to gain bytes, rather think of gaining KB by optimizing about correctly your images. Possibly think of Gzip compression, if to gain bytes obsesses you. ;) - If you work on large sites with strong stresses of performances, should be to you capable set up a mechanism of setting in production, Gzip compression, etc

    Bruno, thank you to be to you leaning on the appeal to contribution. However, I announce just that it is not finalized. It could be even that this project changes of good part of guideline, but nothing is decided for the moment. More news after Paris Web and from here the end of the year. (It may be that I solicit you, Bruno, if the project news grinding is confirmed. But . : D)

  7.  
    7 Bruno spoke on November 4th, 2008 with 19:56 |
     

    @Yves: With regard to the validation of the style sheets, it is true that with the air rather little used.

    @Nicolas F.: I saw your contribution on the Google Group: not badly of similarities indeed! If not, for the writing of the statements on only one line, and to say the content of my thought, I acknowledge not to understand how one can find that practices… But good, tastes and colors (without speaking about the bad habits of work: D)…

    @Dievochka: My are often rather long and yet I not much: I misuse the synopses and Ctrl F! In general, I seek a selector in a after having thrown an eye with , then, it very fast of is copied the class or the identifier and to stick it in limps of search of the HTML editor;)

    @Slim: Ca has of you to escape, but I precisely approach the use of to optimize the not to let human do the work of a machine;)

    V @Florent.: On the principle I am of agreement to have a file of work and another for the production. In practice and within the framework of an environment where it is necessary to go quickly and where the speakers is numerous, it is much more .

    If not, I had seen well that your appeal was under development, but I precisely had a draft more or less on this set of themes, then, I jumped on the occasion: is not necessary to waste;)

  8. 8 spoke on November 5th, 2008 with 11:56 |
     

    very good item which enables me to see there more clearly on certain points and a method which will be able to inspire to me for mine ..... that I always seek!!

    thank you with you

  9. 9 Guillaume spoke on November 19th, 2008 with 15:35 |
     

    @Bruno: gives even the line number or is the statement in the style sheet, small a Ctrl G and one is there.

Take part in the item

Your email never will not be published or will be revealed.

Enrich your comment with syntax.

To follow the comments of this bank note by RSS?