GRC 339: Resources

Be creative on your mistakes

Here’s how you can avoid the ones everybody else makes.

After each mistake, if you see the symbol, you can click on it to find more information.

Basics

  1. All your content should be in the <body> of your document, including headers and footers. 

  2. Close all the tags you opened. (Don’t forget to close <body> and <html>.) 

  3. All the pages need to have a <title> in the <head>

  4. All quotes in the code (not in the content) need to be straight quotes ("" not “”). It won’t work otherwise. (If you copy your code from another program, it’ll likely come with “smart quote” rather than the straight quotes. And it will break your code.) 

  5. In the content, however, use proper apostrophes, quotes, and dashes. 

  6. Your homepage file needs to be named index.html or you will get an error. 

  7. You can’t just make up HTML tags. Please, check the list of all valid HTML elements.

  8. Don’t use images or PDFs for content.

Type hierarchy

  1. Pieces of text with the same hierarchy should have the same tag. (ph2, h3, etc.) You may, for example, use many <h2> tags throughout your page. (But you only want one h1>.)

  2. Don’t include a <p> tag inside a heading tag (<h1>, <h2>, etc). 

  3. There’s no p2

  4. There’s no h7

  5. List items need to live inside lists. 

  6. Only list items can be nested inside a list. (Nested inside the list item, though, you may have other elements, such as headings and paragraphs.) 

  7. Avoid line breaks (<br />). Use lists or new paragraphs and style them properly. (That’s not to say that any use of line break is a mistake. The tag exists for a reason, and it’s helpful for addresses or business hours, for example.)

Style

  1. Don’t include styling on your HTML document. 

  2. Don’t include HTML tags in your CSS files either.

  3. One CSS file should hold all the formatting for your website. Don’t use a different CSS file for each HTML file.

  4. Try not to make different styles for each page either. Your goal is to make them as consistent as possible.

  5. Declare all colors as color values, using rgb(x, x, x) or #xxxxxx, or hsl(x, x%, x%). Don’t use the color names. 

  6. Paragraphs (p) and list litems must be at least 1em. (Ideally exactly 1em. Or in other words, leave their size alone, respecting the users’ preferences.) 

  7. If two pieces of information have the same hierarchy but should look different, use classes. (Don‘t make h3 and h4 have the same visual hierarchy but with different colors.)

  8. Don’t use <i>, <em>, <b>, or <strong> on a whole element or paragraph. Also, make sure you’re using them for the right semantic reasons. Use the <span> tag if it makes more sense.

  9. Don’t use all caps on your HTML file. Use the text-transform property on CSS instead.

  10. Don’t use px for anything but borders. For everything else use only % and em or rem, as appropriate.

  11. Don’t use pt either. Use only em (or rem) for font-size.

  12. Don’t use negative margins (or negative paddings). Use Eric Meyer’s Reset CSS tool if you don’t want to deal with default margins messing with your document’s style.

  13. Use margins and paddings to clear area around content only. (If you use margins bigger than 3rem or 5rem, it’ll probably break the layout.)

Classes

  1. Don’t put classes in the closing tag of the element.

  2. Be as economical as possible with your classes. In other words, use as many classes as you need, but no more than that.

  3. Use semantic names for the classes. (i.e. “price” rather than “redtype”.)

  4. “Container” is the div around the content of your page. The other divs should be named semantically.

  5. All class names should be lowercase and have no spaces. Also, they should not start with numbers and should be short (up to 12 or 15 characters).

Images

  1. Every image on your HTML document must have the alt attribute.

  2. Use the alt attribute on the image to be as descriptive as possible. Remember, that’s what users will read if they can’t see the image.

  3. Include a period in the end of all alt attribute text. It causes screen readers to pause slightly, making for a better reading experience. 

  4. You don’t need to include “picture of”, “image of”, or “photo of” in the alt attribute of the img tag. (“Hamburger on a plate.” rather than “Photo of a hamburger on a plate.”)

  5. All file names should be lowercase and contain no spaces.

  6. Keep all the images in your server. (Don’t link to an external image on another website, download it and upload it to your website instead.)

  7. It’s good practice to keep the images in another folder. (Optional)

  8. Do not save photos as GIFs. Photos and rich illustrations should be JPEGs (or PNGs if transparency is needed).

  9. Don’t use the width and height attributes on the img tags. (Style them in the CSS, instead.)

Links

  1. Links within your website should be only the name of the file (e.g. index.html, contact.html, etc.), and not a big link to a file on your computer.

  2. Links within your website (internal links) don’t need full URL either.

  3. External links need full URL (http://www.example.com or https://www.example.com). But don’t use the target="_blank" attribute to force them to open in a new tab or window.

Troubleshooting

  1. If nothing on CSS seems to be affecting your page, make sure you have all the right curly brackets (}) in place.

  2. Another common problem is forgetting to include colons and semicolons on each property of the CSS. (property: value;)

  3. If it still doesn’t work, make sure you’re working on the right files. (Change some word on h1 to check if the HTML file is right, or give the body a background color to check it the CSS file is correct.)

Always check your work on multiple devices, browsers, and window sizes.