Is there a standard for structuring an HTML site?

Asked

Viewed 384 times

3

I am creating a website and have the following structure:

<body>
<div class="container">

    <?php require_once('includes/header.php'); ?>
    <?php require_once('includes/main.php'); ?>


</div>
<?php require_once('includes/footer.php'); ?>

It’s working normal, but I don’t know if I’m doing it right, the footer is outside the container div, if I put it inside it it doesn’t stay at the bottom of the site. would like to know from those who know well the development of sites which is the best structure for the development of sites.

  • It depends on the requirements of its application, that is, it varies greatly according to its objective. For example, considering that the class container comes from Bootstrap CSS, it has a width defined according to the size of the screen. If you need a footer with 100% of the width of the screen, you need to have it outside the div. Sometimes it is interesting to leave it in. It depends a lot.

  • It’s pure, there’s no framework.

  • 1

    Look, it’s probably outside the scope, the way it is, maybe if it changed to "there’s a blah blah pattern," but I don’t know how to let the community evaluate... Check out this link https://www.w3.org/wiki/HTML_structural_elements ... The element structure is linked to the DOM tree that browsers mount, now the positioning is relative to css, you can have 2 types of structure, with the same visual adjusted by css... now if I’m not mistaken you are expected a certain example structure, semantically header should in my opinion come before container, the main ...

  • Even so. There is no way correct to ask. Your question is too broad.

  • should be the container and then the footer, all within the body...

  • @Andersoncarloswoss I think you expressed yourself badly, I believe there can be several correct ways...

  • Anderson, the problem is I don’t know what’s the best way to do it, according to the closest way to a pattern.;..

  • @Magichat, yes, it would have been better to highlight the "one" instead of the "correct", but what I meant is exactly this: there is not only one way to do it or one that is absolutely correct.

  • There may be more than one footer per section and it may have different order @Magichat ... this question is totally opinionated.

  • @Guilhermenascimento yes, at no time I said that I was not (I still talked about it in my first comment), but anyway there is a standard, convention I don’t know the name, and the most important validators... And yet in my reply I addressed his point of view through uniqueness...(I always wanted to use that word, heuheu),,,

Show 5 more comments

2 answers

3


The recommended structure for an HTML5 page in your case could be like this:

<!DOCTYPE html>
<html>
<head>
<title>título da página</title>
</head>
<body>
    <nav>menu principal</nav>
    <header>
       <?php require_once('includes/header.php'); ?>
    </header>
    <main>
      <?php require_once('includes/main.php'); ?>
    </main>
    <footer>
       <?php require_once('includes/footer.php'); ?>
    </footer>
</body>
</html>

The "NAV" tag can be inside "HEADER" if you prefer. So your code will be more semantic and using the Html5 tags makes indexing by search engines easier. Regarding the footer, there are several ways to keep it fixed at the base of the window, see here 5 ways to do this.

3

The standard structure for a document html is the following :

<!DOCTYPE><!--Document Type Definition-->
<html>
    <head>Meta dados</head>
    <body>Conteúdo</body>
</html>

Source

Now, inside the body you can assemble various type of layout... Where believe (I have no sources) that there is a sequence, being header,content,footer, but this can vary greatly depending on the DTD and other details that make each purpose unique...

Anyway you can use one of the many validators, for example : Validator.W3.org

And here you can see information on the global standard.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.