Week 2: HTML/CSS Pt. 2-UX/UI Design

 

 “Genius is 1% inspiration, 99% perspiration.”

-Thomas Jefferson

Week 2 | Overview


COMMENTING YOUR CODE

You can place a comment tag in your HTML to put a note into the code that will not be rendered by the browser. This is especially handy in a long and complex page. A comment is formatted as follows:

<!-- This is a comment -->

Everything between the <!– and –> tags will be hidden from the browser, but visible when you view the source.


COLOR

All color in Web pages, whether it is in text, background color, or other interface elements, is expressed in the HTML via hexidecimal codes. These codes consist of a # followed by 6 letters and numbers. For example, the code for white is #FFFFFF.

Below are two excellent references for the hex codes for the Web-safe palette.The Web-safe palette is a collection of colors that have been determined to be consistently rendered across boundaries.

Webmonkey Color Code Chart
Visibone Webmaster’s Palette


FONTS

Because a Web browser can only utilize those fonts installed on the end-user’s machine, there are a limited number of fonts reliably available across platforms. Here’s an up-to-date list of them:

Web Safe Fonts for Mac & PC

You should only use these fonts, or generic font designations, in your style sheets.

Here is a great resource for viewing how Web fonts will look in a browswer:

Typetester


META DATA

Meta data is located within the <head> of a web page. Your meta data is basically information that you insert that explains what this page/site is all about. Copy and past the code text below into your head:

  1. Keywords:
    Information inside a meta element describes the document’s keywords.
    The Code Looks Like this:
    <meta name="keywords" content="HTML, DHTML, CSS, XML, XHTML, JavaScript, VBScript">
  2. Description:
    Information inside a meta element describes the document.
    The Code Looks Like this:
    <meta name="description" content="Free Web tutorials on HTML, CSS, XML, and XHTML"/>

WHAT IS CSS?

  • Cascading Style Sheets (CSS) are a standard developed to allow designers control over presentational elements of a Web page and effectively separate content from presentation.
  • A style is a group of attributes that are called by a single name.
  • A style sheet is a group of styles.
  • The cascade part of CSS means that more than one stylesheet can be attached to a document, and all of them can influence the presentation. It also means that different applications of CSS can be applied to a page in order of precedence: inline, embedded, external and default.

Basic CSS Tutorial



THE CSS BOX MODEL, TYPES OF ELEMENTS

boxmodel

The three types of HTML elements to apply styles to:

An important concept to understand is that there are basically three types of HTML tags: block-level elements, inline elements, and replaced tags.

  1. Think of block-level elements as boxes that have a line break before and after. Block-level elements are the ones you will spend most of your time applying style rules to, or manipulating with scripting. They include h1-h6, p, div, ul, ol, blockquote.
  1. Inline elements
  1.  on the other hand, don’t have line breaks before and after. Inline elements are used in the middle of another element, and include a, b, strong, italic, em, span
  2. The third kind of HTML tag is called a replaced tag. What it means is simply that these elements have a set width and height. The most-used replaced tag is the <img> tag, which you must specify a height and width for.

If an element is not explicitly defined, it is known as an anonymous element.You will not be able to style this element directly.


CSS SYNTAX
css selector

 

 

 

 

 

 

 

 

The CSS syntax is a little different from the tag and attribute format of HTML. A CSS style is made up of a selector, which is the HTML element or class name you wish to define rules for, and a set of properties and values. A property and its value are separated by a colon (:). You can define multiple properties for a style, separating them with a semi-colon(;). Property/value sets are enclosed in brackets{}.

For example, if you wanted to redefine all HTML in your <p> tags to look like this, then your style would look like this:

p {
color: #00CC00;
font-size: 13px;
font-family: "Courier New", Courier, monospace;
font-weight: bold; text-decoration:none;
}

The order of properties doesn’t matter, as long as you separate them with a semi-colon. Property values that have multiple words are surrounded by double quotes: “Courier New”.

You can apply the same style to multiple selectors by grouping them:

h1, h2, h3, h4 {

color: #00CC00
}

There is a full CSS reference and extensive code examples at:

W3 Schools CSS Tutorial

also at: http://www.barelyfitz.com/screencast/html-training/css/positioning/


Sizing in CSS

There are a number of different measurement schemas within xHTML / CSS. Which one to use depends on context, and you can mix and match them.

  • px – number of pixels, relative to the screen size. This is the most consistent across machines, browsers, monitors
  • % – percentage of the total width or height
  • em – size relative to the em size of the base font

We will go into when it is appropriate to use the various schemes in later weeks. For now, use the px units in your stylesheets.


 

CLASSES AND IDS

Classes and Ids are a way to designate specific elements in your HTML. You can apply either a class or id or both to any element:

<div id="navigation">

<p>

There is one key difference between a classes and ids:

  • IDs can only be applied to one element per page
  • Classes can be applied to multiple elements per page

When naming classes and ids, it is good practice to name them logically and semantically. The names should not describe the physical attributes of the style you plan to apply to them, but the type of thing that they are in the structure of your page. For example, if you have a unordered list of links that will serve as your navigation, this:

<ul id = "navigation">

is better than this:

<ul id = "top">

The reason for this once again we want to separate the structure from the presentation. Naming your classes and ids logically means that if you radically change the color scheme or layout defined by your style sheet, the structure will still make sense.