HTML, or Hypertext Markup Language, uses what is called a tag structure to markup text. A tag consists of a command inside <> with a closing tag > at the end of the block. In the above example, you can see four such pairs (html, head, body, title). HTML is not programming in the sense of logic, but is simply used to tell a web browser how to render text. In other words, we can specify if certain text should be bold or red or big, etc.
When the WWW started, HTML was kind of like the wild west: very few rules. In recent years, with the inception of smart phones and tablet devices, the W3C (World Wide Web Consortium) has created standards that should render similarly on a variety of browsers, platforms, and devices. Let's take a quick look at some of the standards represented in this document:
The document begins with a !DOCTYPE singleton tag that specifies html as the document type
Each of the tags is written in lowercase.
Each tag is paired with a closing tag
Tags are properly nested (interior tags close before exterior tags)
<!DOCTYPE html>
<html>
<head>
<title>This is the title</title>
</head>
<body>
This is the main content.
</body>
</html>
HTML 5
HTML 5 is the next generation of HTML. Built out of a need for simple, valid, cross browser, cross platform web applications, HTML 5 supports mobile devices and reduces/eliminates the need for multimedia plugins. HTML 5 also provides semantic markup to better identify the coded sections of a web page AND provides a means of storing data client side for web applications across pages.
section - used for grouping together related content. Items in sections would be appropriate to include in an outline of a site.
article - a stand-alone set of information that could act independently of the website
aside - information that is related to the topic - often used as a side bar
Other Useful Tags
Tables
table - marks the start and end of the table
tr - marks the start and end of a row
th - marks the start and end of a header cell (auto bold and center)
td - makrd the start and end of a cell
Forms
form - marks the start and end of form data
input - allows for many types of input. Utilizes the type attribute. Possible input types include: text, password, email, url, tel, radio, checkbox, submit. input is a singleton tag. Also, HTML5 has added new attributes including placeholder, autofocus and required. Finally, remember that all form elements should have both an id AND name attribute for processing purposes.
label - used to link a form label to the appropriate input element. The label element requires the use of the for attribute which should be set to the id of the target form element.
select - creates a drop down list or multiple selection list. Used in conjunction with the option element (required value attribute) to create the list options. Use the multiple attribute in the select tag to allow multiple selections.
textarea - used to create multiple line input areas for users. Requires the use of the rows and cols attributes to assign size.
Lists
ul - used to start and end an unordered (bulleted) list
ol - used to start and end an ordered (numbered) list
li - used to start and end an item in a list
img - used to display an image. img is a singleton tag AND requires the use of the src attribute. All src attributes pointing to images stored in the site should be written relatively.
a - used to mark the start and end of a link to another location or file. The a tag requires the use of the href attribute. All href attributes pointing to files stored in the site should be written relatively.
h1 - used to mark the start and end of a level one header. This type of title is used to be the main, visible header on a page. There are other header elements including h2...h6 where as the number of the header increases, its resulting size decreases.
div - a non-formatted, block level element used to denote divisions within a web page.
span - a non-formatted, inline element used to denote divisions within a web page.
CSS Basics
CSS stands for Cascading Style Sheets. A style is a rule that tells the browser how to render a piece of html code. Styles should be used for design, while html should be used to structure content. CSS styles are written in type/value pairs where the type and value are separated by a colon (:) and multiple rules are separated by a semicolon (;).
Styles can be applied in many ways:
Directly to an element (e.g.: body). This will effect all elements of that type within the style range.
To an id (e.g.: #zone1). This will effect only the elements with that id. Remember, id's should be unique within a page.
To a class (e.g.: .blue). This will affect all elements that have applied that class.
To nested elements (e.g.: div h1). This will affect all h1 elements inside a div tag.
To multiple elements (e.g.: span,nav). This will affect all span and nav elements within the reach of the style.
There are three ways to apply styles to an html element: external, internal and inline. External style sheets are used to apply styles on a site level basis. They are written in .css files and are included in the html document using the <link> element. The benefit of external style sheets is that styles can be applied to all pages in a site by linking the style sheet to each page. This makes sitewide changes fast and easy.
Internal styles are used to apply styles on a page level basis. They are written in the html file inside the <style> tags that should be located in the head element. If a page uses both an external and internal style sheet and there are conflicting rules, CSS dictates that the closest style will be the style applied. So, an internal style would take precedent over an external style.
Finally, inline styles are used to apply a style on an element level basis. They are written as an attribute of a tag. Inline styles are the most local version of a style, so, in the case of conflicting styles, an inline style will always take precedence.
font-family: a comma separated list of possible fonts
text-align: left | center | right
Borders/Margins/Padding
border: width style color, can be assigned separately AND can set border sides separately (e.g. border-top)
margin:sets the space around an element to any value in px, can be assigned separately (e.g. margin-top)
padding: sets the space inside an element to any value in px, can be assigned separately (e.g. padding-top)
display: none | inline | block; changes the display type of an element. none hides the element, inline removes line breaks before and after, block adds line breaks before and after.
Positioning
position: absolute | relative | fixed; absolute positioning places the element in pixels as measured from the upper left corner of the page (0,0); relative positioning places the element in pixels as measured from where the element is placed by the html; fixed positioning places an element in a position and fixes it there so if scrolling takes place, the element will not move.
top: placement from the top in pixles (there is also a type for bottom, left and right)
z-index: an integer that sets the layer level for visibility. The position type must be set in order to use z-index.
float left | right, pushes an element to the left or right allowing other element to wrap around it.