Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The best advice I've heard on learning to use html/css layout goes something like this:</p> <p>When building a new page, don't try to get all fancy up front. Start by building a very basic, text-only page. It should look like something from 1996- that brief period where everyone had just discovered the web but had not yet started using the <code>table</code> tag for layout- only no comic sans font. Don't use images at this point, unless the image is genuinely a part of the information being conveyed (as opposed to the window dressing to make it look pretty: you can add those later). There will likely be an <code>h1</code> at the top of the page, and give each sub heading an appropriate <code>hN</code>, but at this point there shouldn't be any layout information in the page at all. The only place you'll have a <code>table</code> tag is if you genuinely have tabular data to show. If it helps you write this code then you can wrap everything in old-fashioned <code>&lt;center&gt;</code> tags for now- just don't forget to remove them later.</p> <p>Now let's start tweaking the markup a little. Use things like <code>ul</code> (unordered list) for your <em>list</em> of navigation links and <code>label</code>/<code>legend</code> to identify and group your form areas. The general idea here is to have each element on the page encased in the most appropriate html tag, and to use the full set of available tags- each for it's designated purpose.</p> <p>At this point you have a page that is ideally suited for a screen reader or search engine. By building this page first, you have made SEO and accessibility compliance easy on yourself. Of course those aren't the only requirements, so we're not done yet.</p> <p>Now you need to identify the different sections of your page, from both the layout <em>and</em> logical perspectives. The page should largely already be divided logically, but you may find a few places where the normal tags don't cut it. You'll also want to group certain elements for layout reasons. Encase each of these areas with a <code>div</code> tag, and give the tag a class name that refers to the purpose for the tag: the group your are creating. This is just another case of using the a tag (the "division" tag) for it's intended purpose. Also, since elements can have more than one class, you may want to think about also grouping your classes logically. For example, you might want to have a separate class that distinguishes the site template from the rest of the page. </p> <p>By and large this should not have changed the appearance of the page, but now you have something where it should be very easy to start adding styles. At this point you can now start adding images and layout. The goal here, though, is to change the actual markup as little as possible. If you can manage it only add ids and classes, though you will likely need to add an additional span or div that you had not identified earlier, and sometimes you'll need an extra block level element to force a compatible layout across browsers.</p> <p>If things are done correctly, the result is a page that not only looks good, but is also easier to work with when testing across browsers, will naturally degrade well when a style or javascript feature isn't supported, and scores well for SEO and accessibility. This also makes it easier to have a developer build a simple page that provides a certain level of functionality, which they can this pass off to a separate designer to make it look good.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload