Aquesta pàgina forma part de la documentació de Moodle en català, tot i que no ha estat traduïda encara. Podeu contribuir obertament a les tasques de traducció. Podeu consultar la Guia d'edició de la documentació i també participar ens els debats del fòrum de traductors de la documentació a moodle.org

Semantic HTML: diferència entre les revisions

De MoodleDocs
Salta a:navegació, cerca
Línia 81: Línia 81:
(Example taken from one of Moodle's standard themes.)
(Example taken from one of Moodle's standard themes.)


== Divitis ==
== "Divitis" ==


"The biggest problem with div tags is that they are used too often. Divs should only be used to build structure and as placeholders for design elements when no other block-level elements can describe the content."
"The div tag is a block-level element that defines a section within a document. Divs are thus suitable for building the structure of Web pages. The div tag is also used to describe content that cannot be properly described by other more semantic tags. When developers do not understand the semantic meaning of other block-level elements, they often add more div tags than are needed."  


Source: [http://www.smashingmagazine.com/2009/04/08/from-table-hell-to-div-hell/ "Table Layouts vs. Div Layouts: From Hell to… Hell?"]
Source: [http://www.smashingmagazine.com/2009/04/08/from-table-hell-to-div-hell/ "Table Layouts vs. Div Layouts: From Hell to… Hell?"] from ''Smashing Magazine''


== Further resources ==
== Further resources ==

Revisió del 13:26, 11 juny 2009

The case for semantic HTML

It is easy to create HTML that works, but current best practice suggests that creating valid and Semantic HTML is an important goal for various reasons including usability and accessibility.

Unfortunately, while validation is a relatively easy task to understand and achieve, creating semantically correct HTML is a lot more subjective and open to debate.

Examples for semantic HTML

Here are some examples of non-semantic HTML taken from the current Moodle markup (layout and styling is done with CSS which isn't shown here).

List instead of DIVs

BAD:

 <a href="#" name="d16">
   <img id="vh_div16indicator" src="pix/closed.gif" alt="Closed folder">
     Security
 </a>

GOOD:

  • <a href="#">Security</a>
  • (Example taken from Moodle's Site Administration block, see Frank Ralf/Semantic HTML1.)

    Indentation without spacer.gif

    BAD:

    <tbody> </tbody>
         <img class="spacer" src="pix/spacer.gif" alt="" height="10" width="20">
         
         <a href="/course/category.php?id=3">Quizzes</a>
    
    1

    GOOD:

    • <a href="/course/category.php?id=3">Quizzes</a>1

    (Example from Moodle's Course Category list, see Frank Ralf/Semantic HTML4.)


    Separating structure and styling

    Don't use inline styles but put any styling information in a separate CSS.

    BAD:

    GOOD: <style type="text/css"> </style>

    (Example taken from one of Moodle's standard themes.)

    "Divitis"

    "The div tag is a block-level element that defines a section within a document. Divs are thus suitable for building the structure of Web pages. The div tag is also used to describe content that cannot be properly described by other more semantic tags. When developers do not understand the semantic meaning of other block-level elements, they often add more div tags than are needed."

    Source: "Table Layouts vs. Div Layouts: From Hell to… Hell?" from Smashing Magazine

    Further resources

    Online:

    Books:

    Bold text

    See also