Posts tagged Web Design

Website Layout

What is generally accept as a “good website layout”? A subject of debate, however, a good layout will have a clearly defined header area, sidebar (optional), content area, and footer area. It can look like the following:

layout

The sidebar can be neglected, on the left side, the right side, or on both sides. The fact still remains that there is a clear cut header, sidebar, content area, and footer, however.
Note: the widths and height of these elements will differ of course.

Tables or CSS?

Starting with CSS2.1 in table designed websites started to phase out rapidly. This is because rich content management systems like WordPress, Drupal, and Joomla were being born and refined. The developers of these fine CMSs did not use tables to do their bidding for their rich admin panels and client-side website interactivity. Today, tables are nearly deprecated when it comes to web layout. CSS is used to create tableless layouts. If you don’t know CSS and you want to learn CSS you can click here to learn it!

How to Start?

When I start a website I will work on my external style sheet first and foremost. I will set all of the link colors, define by background, etc… Like the following example:

html, body {
     margin:0;
     padding:0;
}
body {
     margin:auto;
     width:1000px;
     background:#3b3b3b url (bg.png) repeat-x top center;
     font-family: Tahoma, Arial, sans serif;
     font-size:12px;
     color:#fff;
}
a, a:visited {
     text-decoration:underline;
     color:#ff9300;
     outline:none;
}
a:hover {
     text-decoration:none;
     color:#ff9300;
     outline:none;
}
img {border:none;}

Once I have my foundation elements all set and ready to go I will create my ID selectors that I will use for the website. If you are unfamiliar with ID selectors or just want a refresher click here for basics or click here for id v. class selectors. The main ID selectors we want are the following:

  • header
  • sidebar (optional)
  • content
  • footer

The CSS could look like the following:

#header {
     height:75px;
     background:#4c4c4c url(images/header-bg.gif) repeat-x;
     border:2px solid #fff;
}
#sidebar {
     float:left;
     width:150px;
     background:#DBDBDB url(images/sidebar-bg.gif) repeat-x;
}
#content {
     float:right;
     width:850px;
}
#footer {
     clear:both;
     height:75px;
     background-color:#4c4c4c;
}

The HTML code to make this happen would be the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
  <div id="header">
    <p>Add content here</p>
  </div>
  <div id="sidebar">
    <p>content here</p>
  </div>
  <div id="content">
    <p>content here</p>
  </div>
  <div id="footer">
    <p>content here</p>
  </div>
</body>
</html>

We are using a div element that is a block level element so we can negate display:block; for the ID selector. It is common practice that we use div elements to call certain ID selectors since div, by default, does nothing.

Once we have the basic structure of the website we can add our custom styles, class selectors, additional class selectors, nested selectors, pseudo-classes, pseudo-elements, etc… Consider the following for the sidebar:

 #sidebar.container {
     background:#DBDBDB url(images/gradient.png) repeat-x top top;
     width:125px;
     max-height:250px;
     overflow:hidden;
}

This creates a class selector called container which can only be used for the ID called sidebar. This container will be called multiple times in the sidebar (hence, the class selector) and will reside inside the sidebar since it’s a child element.

Want to see a working example and then some? Please download web-layout.zip where you can see multiple examples of web layouts each with a combined and their own individual style sheet so you can easily see what the CSS is doing to each layout.

web-layout.zip
web-layout.zip
Size: 14.43 KB

Creating an Inline Menu

Creating an inline menu should seem pretty straight forward, right? You think we could just create an unordered list and that would be the end of the story. Unfortunately, if we create an unordered list we’ll quickly see that these lists types merely list item one on top of the other.

  • Item 1
  • Item 2
  • Item 3

This is because the ul and li elements are block-level elements and not inline elements. For example:

ul, li {display:block;}

Is a piece of code that is understood by every modern browser that follows the W3C standards.

Our solution is simple then. If we recall that an inline display value will use only what is immediately around the element. Consider the following:

p.inline {display:inline;}
<p class="inline">Porttitor eros dictumst nunc lundium porta proin
ultrices placerat velit ultrices parturient tincidunt?
In. Nisi tincidunt scelerisque cras velit sed risus
arcu turpis! Mauris et.</p>
<p class="inline">Et ac. Nec tortor quis pulvinar tristique augue
dis sed adipiscing aenean nascetur arcu, magna, elit enim cras?
Amet proin, nascetur amet et eu diam.</p>

Since we overrode the default display:block; for p elements, the output will be the following:

Porttitor eros dictumst nunc lundium porta proin ultrices placerat velit ultrices parturient tincidunt? In. Nisi tincidunt scelerisque cras velit sed risus arcu turpis! Mauris et.

Et ac. Nec tortor quis pulvinar tristique augue dis sed adipiscing aenean nascetur arcu, magna, elit enim cras? Amet proin, nascetur amet et eu diam.

So let us examine the list a little bit more.

<ul>
     <li><a href="#">Item 1</a></li>
     <li><span>Item 2</span></li>
     <li><em>Item 3</em></li>
</ul>

The <ul> in itself if a block-level element; however, the <li> are also block-level elements. All of the elements surrounding the list items are inline elementse.g. the <a> is an inline element.

In our inline menu, we don’t want the menu itself to be an inline element but rather its items to be inline elements. These items are the <li> elements. Consider the following menu with basic CSS:

#menu {
     height:50px; /*sets height of menu*/
     background-color:#4c4c4c;
}
#menu ul {
    list-style:none; /*gets rid of bullets*/
     width:800px; /*sets width of menu, not necessary*/
}
#menu li {
     display:inline; /*critical to inline menu*/
     padding-left:10px; /*sets space between menu items*/
}

Now that we have our CSS the HTML structure will look like the following:

<div id="menu">
     <ul>
          <li>Item 1</li>
          <li>Item 2</li>
          <li>Item 3</li>
     </ul>
</div>

See the downloadable file for working example and additional examples.

Pretty boring, huh? All of that CSS for just a few lines of lousy HTML. This is a secret behind the creation of inline CSS menus, just remember that you want the menu items to be a series of inline elements but not the actual menu itself.

From here on out we can style our inline menu to our liking. If you are unfamiliar with CSS then I recommend you visit the CSS Tutorials and learn CSS!

From there we can style our inline menu to our liking. We can create simple effects that will make the men stand out. Consider the following:

#menu {
     height:50px;
     font-size:1.2em;
     background-color:#4c4c4c;
     border:2px solid #fff;
     color:#fff;
}
#menu ul {list-style:none;}
#menu li {
     display:inline;
     padding-left:10px;
}
#menu a:link, #menu a:visited {
     text-decoration:none;
     color:#fff;
     padding:10px;
}
#menu a:hover {
     background-color:#3b3b3b;
     text-decoration:none;
     color:#DBDBDB;
     padding:10px;
}

This will give us a nice looking menu that will have a roll over effect on the links within the menu. From there, we can add custom images, jQuery drop down menus, and many other effects using client-side code.

For examples and editable code, please download the file!

Inline Menu
Inline Menu
Size: 11.48 KB

Introduction to CSS3

As you probably know, CSS stands for Cascading Style Sheet and it used in place of HTML frames, and HTML tables. CSS was created to make web site creation easier and more pragmatic. If you have an external style sheet linked on all pages of your website, this will allow you to make changes all across the site with just a few changes.

Traditionally, you would have to open every page of you site and make the necessary changes. If you had a 20 page site and you decided to change you logo then you’d have to open every page and add that new logo into the pages. With CSS, however, you could change the logo just by changing the image name in your style sheet.

Versions of CSS

CSS1

CSS1 became a w3c recommendation in Dec 17th, 1996 and was last revised on Apr 11th, 2008. CSS1 included many CSS3 properties that are still used today such as margin, padding, border, and background. When CSS1 came out HTML 2.0 was the primary version of HTML. We’re now on (X)HTML 4.01 as the standard.

CSS2

CSS2 included improvements on CSS1 such as a box-model, overflow, and aural style sheets for aria required screen readers.

CSS2.1

Many years later the w3c completed a major revision of CSS2 called CSS2.1 that became recommendation on September 8th, 2009. This includes many fixes on CSS2 and included many new values and new properties that made web design even more simple. At this time HTML 4.01, and XHTML 4.01 were standards at this point in time. When CSS 2.1 was birthed it began to phase out web sites made with HTML tables. CSS2 and CSS 2.1 allowed for a designer to make complex HTML table sites simpler and more practical to amend. This also gave way to very complex internet programs such as Drupal, Joomla, and WordPress (though they existed before 2008).

CSS3

As of March 3rd, 2010, CSS3 is still a working draft by the w3c. Some properties such as border-radius, text-shadow, and border-image are already supported by the latest versions of Chrome, Safari, Firefox, and Opera. For more information on CSS3 you can read the documentation here.

Note: A large sum of these selectors will NOT work in IE versions 5.5-8. To test and see which selectors are buggy and are not supported please visit css3.info’s Selector Test. If you’re using the latest versions of opera, chrome, safari, and Firefox then you needn’t worry.

Some things we will cover

We will cover an extremely useful property called the “text-shadow” property. It can look like the following:

Text-Shadow

Border-Radius

and of course opacity/rgba:

Opacity

Sources:

HTML Color Reference

Sort: A to Z | Z to A | Light to Dark | Dark to Light

Colors Color Names HEX RGB
YellowGreen #9ACD32 154,205,50
Yellow #FFFF00 255,255,0
WhiteSmoke #F5F5F5 245,245,245
White #FFFFFF 255,255,255
Wheat #F5DEB3 245,222,179
Violet #EE82EE 238,130,238
Turquoise #40E0D0 64,224,208
Tomato #FF6347 255,99,71
Thistle #D8BFD8 216,191,216
Teal #008080 0,128,128
Tan #D2B48C 210,180,140
SteelBlue #4682B4 70,130,180
SpringGreen #00FF7F 0,255,127
Snow #FFFAFA 255,250,250
SlateGray #708090 112,128,144
SlateBlue #6A5ACD 106,90,205
SkyBlue #87CEEB 135,206,235
Silver #C0C0C0 192,192,192
Sienna #A0522D 160,82,45
SeaShell #FFF5EE 255,245,238
SeaGreen #2E8B57 46,139,87
SandyBrown #F4A460 244,164,96
Salmon #FA8072 250,128,114
SaddleBrown #8B4513 139,69,19
RoyalBlue #4169E1 65,105,225
RosyBrown #BC8F8F 188,143,143
Red #FF0000 255,0,0
Purple #800080 128,0,128
PowderBlue #B0E0E6 176,224,230
Plum #DDA0DD 221,160,221
Pink #FFC0CB 255,192,203
Peru #CD853F 205,133,63
PeachPuff #FFDAB9 255,218,185
PapayaWhip #FFEFD5 255,239,213
PaleVioletRed #D87093 216,112,147
PaleTurquoise #AFEEEE 175,238,238
PaleGreen #98FB98 152,251,152
PaleGoldenRod #EEE8AA 238,232,170
Orchid #DA70D6 218,112,214
OrangeRed #FF4500 255,69,0
Orange #FFA500 255,165,0
OliveDrab #6B8E23 107,142,35
Olive #808000 128,128,0
OldLace #FDF5E6 253,245,230
Navy #000080 0,0,128
NavajoWhite #FFDEAD 255,222,173
Moccasin #FFE4B5 255,228,181
MistyRose #FFE4E1 255,228,225
MintCream #F5FFFA 245,255,250
MidnightBlue #191970 25,25,112
MediumVioletRed #C71585 199,21,133
MediumTurquoise #48D1CC 72,209,204
MediumSpringGreen #00FA9A 0,250,154
MediumSlateBlue #7B68EE 123,104,238
MediumSeaGreen #3CB371 60,179,113
MediumPurple #9370D8 147,112,216
MediumOrchid #BA55D3 186,85,211
MediumBlue #0000CD 0,0,205
MediumAquaMarine #66CDAA 102,205,170
Maroon #800000 128,0,0
Magenta #FF00FF 255,0,255
Linen #FAF0E6 250,240,230
LimeGreen #32CD32 50,205,50
Lime #00FF00 0,255,0
LightYellow #FFFFE0 255,255,224
LightSteelBlue #B0C4DE 176,196,222
LightSlateGray #778899 119,136,153
LightSkyBlue #87CEFA 135,206,250
LightSeaGreen #20B2AA 32,178,170
LightSalmon #FFA07A 255,160,122
LightPink #FFB6C1 255,182,193
LightGreen #90EE90 144,238,144
LightGray #D3D3D3 211,211,211
LightGoldenRodYellow #FAFAD2 250,250,210
LightCyan #E0FFFF 224,255,255
LightCoral #F08080 240,128,128
LightBlue #ADD8E6 173,216,230
LemonChiffon #FFFACD 255,250,205
LawnGreen #7CFC00 124,252,0
LavenderBlush #FFF0F5 255,240,245
Lavender #E6E6FA 230,230,250
Khaki #F0E68C 240,230,140
Ivory #FFFFF0 255,255,240
Indigo #4B0082 75,0,130
IndianRed #CD5C5C 205,92,92
HotPink #FF69B4 255,105,180
HoneyDew #F0FFF0 240,255,240
GreenYellow #ADFF2F 173,255,47
Green #008000 0,128,0
Gray #808080 128,128,128
GoldenRod #DAA520 218,165,32
Gold #FFD700 255,215,0
GhostWhite #F8F8FF 248,248,255
Gainsboro #DCDCDC 220,220,220
Fuchsia #FF00FF 255,0,255
ForestGreen #228B22 34,139,34
FloralWhite #FFFAF0 255,250,240
FireBrick #B22222 178,34,34
DodgerBlue #1E90FF 30,144,255
DimGray #696969 105,105,105
DeepSkyBlue #00BFFF 0,191,255
DeepPink #FF1493 255,20,147
DarkViolet #9400D3 148,0,211
DarkTurquoise #00CED1 0,206,209
DarkSlateGray #2F4F4F 47,79,79
DarkSlateBlue #483D8B 72,61,139
DarkSeaGreen #8FBC8F 143,188,143
DarkSalmon #E9967A 233,150,122
DarkRed #8B0000 139,0,0
DarkOrchid #9932CC 153,50,204
DarkOrange #FF8C00 255,140,0
DarkOliveGreen #556B2F 85,107,47
DarkMagenta #8B008B 139,0,139
DarkKhaki #BDB76B 189,183,107
DarkGreen #006400 0,100,0
DarkGray #A9A9A9 169,169,169
DarkGoldenRod #B8860B 184,134,11
DarkCyan #008B8B 0,139,139
DarkBlue #00008B 0,0,139
Cyan #00FFFF 0,255,255
Crimson #DC143C 220,20,60
Cornsilk #FFF8DC 255,248,220
CornflowerBlue #6495ED 100,149,237
Coral #FF7F50 255,127,80
Chocolate #D2691E 210,105,30
Chartreuse #7FFF00 127,255,0
CadetBlue #5F9EA0 95,158,160
BurlyWood #DEB887 222,184,135
Brown #A52A2A 165,42,42
BlueViolet #8A2BE2 138,43,226
Blue #0000FF 0,0,255
BlanchedAlmond #FFEBCD 255,235,205
Black #000000 0,0,0
Bisque #FFE4C4 255,228,196
Beige #F5F5DC 245,245,220
Azure #F0FFFF 240,255,255
Aquamarine #7FFFD4 127,255,212
Aqua #00FFFF 0,255,255
AntiqueWhite #FAEBD7 250,235,215
AliceBlue #F0F8FF 240,248,255

Any improvements on this list will give you mention in this blog post and in the downloadable files.

Color Table
Color Table
Size: 15.03 KB

Basics of XHTML – Part #7

One day while browsing the web you stumble upon a quiz on some website and you decide to take it. Whilst taking this quiz you encounter text fields, radio buttons, check boxes, and password fields. You begin to wonder how these are made. Well, you’re in luck because today we’re going to talk about HTML Forms and Input.

Forms

The form area is where we would put our elements such as radio buttons, textboxes, and checkboxes. This is defined by the <form> The syntax is as follows:

<form>
     <!--input elements-->
</form>

Input

The input element is where we actually get the textboxes and radio buttons. This element will take multiple attributes that will define the type of input we want.

Text

Text fields are fields where we type in things such as email addresses, phone numbers, and names. They will look something like the following:

Email Address:


First Name:


Last Name:

The HTML code for this is the following:

<form>
Email Address: <input type="text" name="email" />
<br />
First Name: <input type="text" name="firstname" />
<br />
Last Name: <input type="text" name="lastname" />
</form>

This is useful for contact forms or customer surveys.

Radio Buttons

Radio buttons derive from the original radio buttons. In the olden days you could only have one button pushed in at a time, if you pressed another button then the existing button would pop out and become deactivated. Like these traditional radio buttons, the HTML radio buttons will only allow one selection at a time.

A more commonplace example would be as if you’re filling out a form and it asks you to print your last name and to fill in a bubble below your printed name. You can only fill in one bubble per space.

They look like the following:

Please select your gender:

Male

Female

Decline to state

Notice that we added another attribute to the input element. This is called the value and is used for a default value. Notice how we can only select one item at a time.
The corresponding HTML looks like the following:

<p>Please select your gender:</p>
<form>
<input type="radio" name="sex" value="male" /> Male
<input type="radio" name="sex" value="female" /> Female
<input type="radio" name="sex" value="decline" /> Decline to state
</form>

Checkboxes

Checkboxes are used when we want the user to be able to select multiple options. A common example is if you’re applying for a job and they ask you “select/check all that apply”.

How did you hear about us (Check all that apply):

Friend

Former Employer

Website

Other

Notice that we can select multiple item at once.

The corresponding HTML is the following:

<form>
<input type="checkbox" name="survey" value="friend" /> Friend
<input type="checkbox" name="survey" value="former employer" /> Former Employer
<input type="checkbox" name="survey" value="website" /> Website
<input type="checkbox" name="survey" value="other" /> Other
</form>

Creating a drop down menu

Creating a drop down menu is yet another method for giving users the ability to select an answer or multiple answers if you want. It will look like the following:

Choose one of the following:

The HTML will look like the following:

<form>
     <select name="bikes">
          <option value="tricycle">Tricycle</option>
          <option value="street-bike">Street Bike</option>
          <option value="mtn-bike">Mountain Bike</option>
          <option value="motorbike">Motorbike</option>
     </select>
</form>

Creating a simple text area

With the addition of a text area, this allows the user to write a message on a contact form or allows them to write additional comments on a survey on any given question. It will look like this in your browser:

The HTML will look like the following:

<textarea rows="10" cols="30">
Type your message here...
</textarea>

In most modern browsers, it’ll allow you to extend the size of the text area at your own discretion.

Creating a Submit Button

Creating a submit button is essential to the form as a whole. Although this button would technically anything, “Submit” is the most common. It will look like the this in your browser:

The HTML will look like this:

<form>
<input type="button" value="Submit" />
<input type="button" value="Good Morning!" />
</form>

Any value that you have in the value attribute will reflect upon the button.

Creating a fieldset around data

You might be wondering what in the world fieldset is to being with. A <fieldset> element is a border that surrounds some or all fields in a form. You can also have a legend element within each fieldset to denote the title of the fieldset.

<form>
<fieldset>
<legend>Name</legend>
First Name <input type="text">
Last Name <input type="text">
</fieldset>
<fieldset>
<legend>Address</legend>
Street Address <input type="test"><br />
City: <input type="text">
State: <input type="state" size="2">
Zip: <input type="zip" size="5">
</fieldset>
</form>

If you want to see this code in action then click on the green download button.

form.zip
form.zip
Size: 3.41 KB