Archive for May, 2014

Dreamweaver FAQ2: What’s the ideal size of a web page?

We will get to the answer you are looking for, but get yourself through the beginning paragraph first.

In today’s world, it is very difficult to predict the devices on which your web pages will be ultimately viewed.  That’s why it doesn’t make much sense to tailor fit your website to the dimensions of a single device. To understand the most likely device on which  your web pages are going to be viewed, you must do your research well. Your research will save you time when prioritizing the design for your website and the benefits you will get from it.

This article, Best Screen Resolution to Design Websites, http://www.hobo-web.co.uk/best-screen-size/ provides an insight into popular screen dimensions for 2014 and previous years.

After you have an idea about the device that you will be primarily designing for, you can start designing in those dimensions while allowing your design to load/transform gracefully  on devices with other dimensions. This approach is known as Responsive Design.

Examples of responsive websites:

To check if a website is responsive, drag the handles of your browser window to see if the web page inside morphs itself to fit the new dimensions of the browser window.

http://www.awwwards.com/web-design-awards/education-above-all

http://www.awwwards.com/web-design-awards/webflow-interactions

Responsive design uses a single website with multiple CSS files. The media query information in the CSS file specifies the dimensions of  the display device for which it should be used. This media query in the CSS file tells the browser, “Hello browser, use this CSS file if your display area is N pixels”.

<link rel=”stylesheet” media=”(max-width: 800px)” href=”example.css” />

CSS files combined with media query helps  you create a single website that caters to display devices with different dimensions.

Before you start designing your website, do a deep dive into Responsive Web Design. If you are going to be a web designer for a sufficient period of time, the principles of responsive design will keep you in good stead.

Happy designing!

Dreamweaver FAQ : How do I center align a web page in Dreamweaver?

Purpose of this tutorial

Create a page in Dreamweaver and center-align the contents of the page. If you are looking for the code to center your page, dive directly to the section “Center the Content”. However, if you are new to web design and are getting started with Dreamweaver, I suggest that you go through every step of this tutorial.

Can I do it without knowing CSS?

No. If you aren’t conversant with CSS, I advise you to take a quick class on CSS and come back. You don’t have to go into a lot of depth, just read the essentials. It should not take you more than an hour or a couple of hours at the most.

How do I center a page?

You create a container (DIV) for the other DIVs on the page. When you center-align the container DIV, the rest of the content gets center aligned as well. Simple! While it is not necessary that you use Dreamweaver for the tutorial, some of the steps that are mentioned are very specific to the use of this software. If you are conversant with HTML and CSS, you will do just fine without these steps using the editor of your choice.

Create a new site

Before we proceed to create a page that centers itself with respect to the display, we will first create a site to store all the files we will be creating hereafter.

Before you proceed, create a folder or directory on your computer called FAQ_Tutorials. I am on a Windows computer, and I have created this in my C drive.

  1. Select Site > New Site.
  2. In the Dialog Box that appears, enter the following information.
    1. Site Name: Tutorials on FAQs
    2. Local Site Folder: Click the Browse or Folder icon. Navigate to the FAQ_Tutorials folder on your computer. Click Select Folder.
  3. Click Save.

lesson1_site_creation

That was simple! You now have created a Site with the name Tutorials on FAQs, and the files for this site will reside in the FAQ_Tutorials folder. Great job!

Create a new page

We will now create a web page that we will save in the FAQ_Tutorials folder.

  1. Just to make it easier to manage your files, create a subfolder called “FAQ1_center_webpage” in the FAQ_Tutorials folder.
  2. In Dreamweaver, select File > New. Ensure that the options Blank Page, HTML, and <none> are selected in the New Document Dialog that is displayed.
  3. Click Create.
  4. Select File > Save As.
  5. Navigate to the FAQ1_center_webpage folder.
  6. Save the file with the file name “centering_a_webpage”
  7. Click OK.

Create the Container and Header

For the web page, we will create a container div that will hold the contents of the page. When we center the container, all the contents inside get centered as well.

In the container, we will include three DIV tags: Header, Body, and Footer.

  1. In Title, replace “Untitled Document” with “Centering a web page”
  2. In the Insert panel, select Structure from the menu.
  3. Click Div.
  4. In the Insert Div dialog, enter container in the ID field. Click OK.
  5. Delete “Content for id “container” Goes Here”.
  6. Ensure that the cursor is within the Div. Click Header in the Insert panel.
  7. In ID, select Head and click OK.

You now have a parent container with the Header div tag inside it. Great going!

Style the Header Tag

Let’s style the Header tag so that we can differentiate it from the other Div tags that we are going to create. And for this, you guessed it right; we are going to need some CSS love.

We will style the header to give it a blue background color with white text.

  1. Just after the Title tags in the code view, we will enter the style tags <style></style>.
  2. In between the tags, we will enter this piece of code:

#head{

                    background-color:blue;

                    color:white;

                    }

  1. Click in the Design view. Do you see a blue box with white text in it? Good!

Create the body and the footer

Let’s go ahead and create the other two DIVs below the header.

  1. Ensure that the cursor is after the closing div tag for the header (</header>).
  2. Click Div in the Insert panel.
  3. In the Insert Div dialog, select After Tag and <header id=”head”> from the Insert options.
  4. In ID, enter body, and click OK.
  5. In the Insert Panel, click Footer.
  6. In the Insert Footer dialog, select After Tag, and <div id=”body”> from the Insert options.
  7. In ID, enter foot, and click OK

You have now created a container DIV with three child DIVs (Header, body, and Footer). When you center the container DIV, all the three child DIVs get centered as well.

Style the body div and the footer tag

Follow the procedure described for Header in “Style the Header Div” to add styles for the body and footer Divs. Add the styles below the style for the header.

#body{

                    background-color:yellow;

                    color:black;

                    }

#foot{

                    background-color:red;

                    color:black;

                    }

You should now see three boxes blue, yellow, and red one below the other. If you don’t, go back and see where you went wrong.

Center the content

Now that we have the contents ready, we are going to center them with respect to the browser they are displayed on.

This is what we will do: Define a width for the container, set the top and bottom margins to 0, and the left and right margins to auto. This clears the space to the left and right of the margin allowing the browser to calculate the margin.

While you can add the style for the container tag anywhere, I suggest that you put it above the style for the header because this is the parent tag.

#container{

                    width: 980px;

                    margin:0 auto;

                    }

Preview the page in a browser

  1. Select File > Preview in Browser.
  2. Select the Browser in which you want to preview the page.

The contents of the page should now be center-aligned. Some of the older versions of Internet Explorer might not work with this code. As a workaround you might have to create a class for the body and center-align text. Unless there is a real necessity to support really older versions of browsers, this step is not necessary.

body {                          

text-align:center;

                    }

 

Some useful notes on linking CSS files

In this tutorial, we have used CSS on the same page as that we have designed. However, it is not a good idea to have CSS on every web page if your website has many pages. A better idea is to create a single or few CSS files and link it to the HTML pages. That way, you can make changes at one location and have them reflected across multiple pages.

For example, you can create a CSS file called theme.css and link it to your HTML page.

<head>
<link rel=”stylesheet” type=”text/css” href=”theme.css”>
</head>

Here, the theme.css is the name given to the CSS file. You can choose any name you want. The CSS file here is on the same path as the page to which it is linked. However, if your CSS file is within a folder called CSS, you will have to specify the path as say, “href=/css/theme.css”. See http://compugoddess.com/relative-vs-absolute-links/ for information on relative paths.