Code With Design

Web development, code, design, css, all around programming blog

Get, install, and use light box

Get, install, and use light box

First and foremost, if you do not know what light box is, then I can only assume that you have been living in the dark ages. A lot of sites incorporate this technique to view full sized photos inside of the browser.

Secondly I am going to have to add that this article is about implementing light box. Not creating a light box like plug in.

The first thing that is required for us is to get light box. Where do you get light box. Well the Internet probably has some light box. lets go there.

This is the site that has what we need. If you would like to click that link, upload to the server you will be working on we can get started.

When working with lightbox you will need to include four lines of code into your header. Once added, your header will look like this.

1
2
3
4
<script src="prototype.js" type="text/javascript"><!--mce:0--></script>
<script src="scriptaculous.js?load=effects,builder" type="text/javascript"><!--mce:1--></script>
<script src="lightbox.js" type="text/javascript"><!--mce:2--></script>
<link rel="stylesheet" href="lightbox.css" type="text/css" media="screen" />

The next part to using this script requires us to link to an image using it. This can be done by using a rel path.

1
<a title="Title" rel="lightbox" href="demo-image.jpg">First Image</a>

Note: There are some things that can go wrong when working with lightbox. The first thing that you need to check is that everything is being properly linked to. There are files from the css that can cause lightbox to not function properly.

Also, if you do not see an image or lightbox appear then you may have to check the JavaScript within the body tag. You may have to modify the on load.

posted by Caleb in CSS, javascript and have No Comments

Learning HTML in one short night

Learning HTML in one short night

Introduction

Open up your text editor because it is time to learn HTML in one night. If you are unfamiliar with HTML you should know that it is first and foremost a scripting language. Your server is going to send this file to the person’s computer. This person’s web browser; be it “Chrome”, ”Safari”, ”Opera”, ”Firefox” or “Internet Explorer” is then going to read the information and display it on screen.

This is an in depth look at HTML and how it is structured. In a future article I will include CSS with some CSS3.

HTML stands for hyper text markup language and is written in a standard text editor. (notepad for Windows, text edit for Macintosh) We are going to go ahead and start the tutorial now.

Please make sure that you have a folder, web browser and text editor open on your screen.

Building our first page

Open up your text editor; type in the following code and then save the file as “index.html” Be sure to write the extension. If it saves as “index.html.txt” then open up the folder that the file resides in, write click it go to “properties” on Window or “get info” on a Mac and remove the “.txt” extension.

1
2
3
4
5
6
7
    <html>
    <head>
    </head>
 
    <body>
    </body>
    </html>

The code above doesn’t contain anything special which is why you don’t see anything. In order to add content we are going to add a little more code to demonstrate some content on the screen but first we need to understand what was just added.

The first part of the above code tells the browser that inside is the HTML, in fact everything is until it reaches the closing statement or the bottom of the page. The head tags as you can see “<head></head>” tell the browser where the head information is. This information usually contains the title of the page, some meta data, style tags or links to css files and a little javascrip.

The tags below this are the body tags. Inside of here is where we will be putting all of the page contents which you will see shortly.

The next step is to add a line of code to your website. It is going to be at the very top and will have the type of charset, some meta data and the doctype. For now you do not need to know what it means but know that it is good practice and allows your code to be read properly.

1
2
3
4
5
6
7
8
9
10
    <!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″ />
    <head>
    </head>
 
    <body>
    </body>
    </html>

Now that we have the basic structure of the page setup we can go ahead and add a title. Like everything else it is set in tags and requires no formatting.

1
2
3
<head>
<title>Code With Design</title>
</head>

Note: The naming of the title is important. It will allow search engines and bots to easily find your content and increase your page rank. Make sure it covers what the page is about but don’t make it to long. Search engines don’t like that.

Testing your page

In order to test your page you just need to find the index.html file’s location on your hard disk and double click it. The page will open up in your default browser. If it does not you are going to need to associate a browser with that type of file. You can also open up your web browser and set the URL to the location of the file on your hard disk.

When it comes to testing to see if you have valid code it is as simple as using the W3C validation service offered here. You can test a page by using the URL, copying and pasting or uploading the file directly.

The body of the page

The next step in our quest for knowledge is getting text onto the screen. In order to accomplish this there are some ways to go about doing so. First there is just plain text which I would advise not doing do to styling complications later on. The next type of text is “paragraph” text. This text is displayed in <p></p> tags and is formatted to have spaces on the top of the first line and the bottom of the bottom line. The third main kind of text is heading tags, once again name these accordingly because it will help your pages chances of getting higher in the search engine.

1
2
3
4
5
6
<body>
<h1>This will be shown at an h1 level</h1>
<p>Here is som basic fill text that is only used to display what is needed.</p>
<h2>Difference in size</h2>
<p>As you can tell there is a difference in size between the heading 1 and heading 2 tags. This difference can be changed later on using page styles.</p>
</body>

The bit of code we are going to use is called a div. Div tags can be found throughout websites and are the main structure of formatting. Div tags can be of type class or id and are used with css to change how a website appears on screen. The following is the basic structure of how a div tag works.

1
2
3
4
<div class=”this_is_where_css_is_associated”>
<h1>Article title</h1>
<p>Content goes here.</p>
</div>

Note: The div tag can be formatted with CSS to change the location of this content on the screen along with colors, and size. Also, div tags are often associated with classes over id.

Menus and links

Menus in HTML are commonly created using unordered lists and list items. These tags like as follows <ul>unordered list</ul> and <li>List item</li>. When written these tags are nested meaning that the list item tags inside of the unordered list.

1
2
3
4
<ul>
<li>Menu item 1</li>
<li>Menu item 2</li>
</ul>

It isn’t going to be much of a menu if we cannot click the item and find ourselves on another page. In order to do this we are going to need to add the following code.

1
2
<a href=”http://codewithdesign.com/”>Code With Design</a>
<a href=”some-random-page.php”>Linking internally</a>
1
2
3
4
<ul>
<li><href=”http://codewithdesign.com”>codewithdesign.com</a></li>
<li><href=”http://lirkr.com”>Search engine</a></li>
</ul>

Initially the menu is going to look very bad but there is hope for it yet. The menu is styled this way as a default. Once you add css to the web page it will begin to look better.

Header rules are not as common as they once were do to the increase in proper CSS they were quickly replaced with borders on div tags. If you are looking for a heading rule then you can add the simple code below.

1
<hr></hr>

Note: There is not content inside of this header ruling for a reason. All that is required are the two tags and a line will be created.

Tables

Note: It is best practice to not use tables at all unless you are puling the information form a database. If you choose to make your website layout using tables note that it isn’t considered common practice, it will increase load times, they are messier to work with and all around a bad idea.

Tables are created using the <table></table> tags and consist of nested tags inside. The basic table will look something like this.

1
2
3
4
5
6
7
8
9
10
<table cellspacing=”5px” border=”1px”>
<tr>
<td>Row 1 col 1</td>
<td>Row 1 col 2</td>
</tr>
<tr>
<td>Row 2 col 1</td>
<td>Row 2 col 2</td>
</tr>
</table>

This table was made using cell spacing and a border just to let you see how it is all aligned. Like I have previously stated these are not a good idea unless displaying data and even then there are better ways then tables.

Forms

These are html components that can be used to send information to other pages on the site. These components range in abilities and are often used to pass a username and password to a site. The general way that it is written is as follows:

1
2
3
    <form action=”" method=”" enctype=”multipart/form-data” name=”form-name” id=”form-id”>
 
    </form>

Going through the top line it is obvious that we are going to need to add components within the form tags. The forms id and name should be changed to your choosing are commonly named the same. (ie: name=”form1″ id=”form1″) The action of the form is where you want the information to be posted. This usually means that it will be sent to PHP page.

Components for forms

Components are usually enclosed in label tags which means that you can add generic text that will be grouped with the item itself.

text area

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
    <label>
    <input type=”text” name=”text” id=”text”>
    <label>
 
    <label>
    <input type=”textarea” name=”textarea” id=”textarea”>
    <label>
 
    <label>
    <input type=”checkbox” name=”chkbox” id=”chkbox”>
    <label>
 
    <label>
    <input type=”radio” name=”radio” id=”radio”>
    <label>

Using the above format you can create items such as:

file input field “file”
hidden field to pass data without a field appearing on screen “hidden”
A submit button used to post the form “submit”

posted by Caleb in Web Development and have No Comments

Modifying next and previous posts

Modifying next and previous posts

For most standard Wordpress themes you are stuck with a boring text on the bottom of the screen with a float left and right property. This simple float looks boring however it is a simple solution for going from page to page.

The below image is what my personal blog used to have for a page navigation. This was to simple for what I wanted which made me want to change it to fit the rest of the page style. The solution was a work through of the CSS requiring a little CSS3 to make the borders rounded.

The final result looks as follows:

The first thing we are going to need to do is open up the style.css and the index.php inside of the theme you are intending to modify.

Wordpress Root -> wp-content -> themes -> theme_name

Once you have opened up the two files, refer to the index.php and scroll down past the post loops to get to your code that checks for posts and allows you to go forward and backwards in post history. The code should look as follows:

<div>
<h5 class=”float-right”>
<?php previous_posts_link(‘Newer Entries &rarr;’) ?>
</h5>
<h5 class=”float-left”>
<?php next_posts_link(‘&larr; Older Entries’) ?>
</h5>
<div></div>
</div>

As you can see there is a float class above which is in our css file as:

.float-right {

float:right;

}

We could change the float class to have a background and a border but that would change everything that uses the float class. In order to change this we are going to have to create new classes and change the index code. For this I will be changing the index code to “post_new_entries” and “post_old_entries.”

The “index.php” will now look something like this:

<div>
<h5 class=”post_new_entries”>
<?php previous_posts_link(‘Newer Entries &rarr;’) ?>
</h5>
<h5 class=”post_old_entries”>
<?php next_posts_link(‘&larr; Older Entries’) ?>
</h5>
<div></div>
</div>

The final thing to do in this modification is to create the classes inside of the “style.css” file. The first thing that is required for the modification is for us to make them float to their designated sides just like the previous floats from before.

.post_old_entries {
float:left;
font:bold 20px/20px Georgia, “Times New Roman”, Times, serif;
}

The rest of the code is fully customizable and up to you. There is always the option of adding hovers and link colors as well as paddings, backgrounds and borders. The code that is currently used for code with design is as follows:

.post_old_entries {
float:left;
font:bold 20px/20px Georgia, “Times New Roman”, Times, serif;
margin-left:-31px;
padding:5px 15px;
background: #f2f2f2;
border: 1px solid #ddd;
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius:5px;
-moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px;
}
.post_old_entries a{
color:#666666;
}
.post_old_entries a:hover {
color:#333333;
}
.post_new_entries {
float:right;
font:bold 20px/20px Georgia, “Times New Roman”, Times, serif;
margin-right:-31px;
padding:5px 15px;
background: #f2f2f2;
border: 1px solid #ddd;
-moz-border-radius-topright: 5px;
-webkit-border-top-right-radius:5px;
-moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px;
}
.post_new_entries a {
color:#666666;
}
.post_new_entries a:hover {
color:#333333;
}

Best of luck with your Wordpress modifications.

posted by Caleb in CSS, Web Development and have No Comments

Creating a fixed header and Footer

Creating a fixed header and Footer

If you are looking for a fixed header of fixed footer you have come to the right place. In this tutorial I will be going over the basic page setup for sections of content, the header bar, footer bar, CSS and HTML.

The CSS code for a header is quite simple depending on how you would like it to interact with the rest of the page.

#header {
top:0px;
right:20px;
left:20px;
position:fixed;
background: #eee;
border:1px solid #ccc;
padding: 0 10px 0 20px;
}
#header h1 {
margin: 0px;
padding: opx;
font:18px “Plantagenet Cherokee”;
letter-spacing:2px;
}

The above CSS contains the header div and the H1 tag. There are four very important things that are required when having a fixed header. First: It must have the position set to fixed. The other three are all about positioning and linking it to the top and sides. With the above code we set the sides to link 20px from the browser and the top to link directly.

Another important part of the CSS is having the page contents forced below what the header is covering. This will allow us to see div that is underneath. That chunk of CSS looks like this.

body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0;
padding: 0;
text-align: center;
color: #000000;
margin-top:40px;
}

The HTML looks something like this.

<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Code With Design Fixed Header</title>
<link href=”style.css” rel=”stylesheet” type=”text/css” />
</head>

<body>
<div id=”header”>
<h1>Header</h1>
<!– end #header –></div>
<div id=”container”>
<div id=”mainContent”>
<h1> Main Content </h1>
</div>
<div id=”footer”>
<p>Footer</p>
</div>
</div>
</body>
</html>

Generally the header is kept withing the container to keep it aligned with the rest of the page however we wanted it to break out of the rest of the page and thus we moved it up, out and away.

The rest of this article will cover the footer which is very similar except for a few things. The footers CSS is going to be fixed to the bottom and not the top which is unlike the header. We will also need to pull it out of the HTML so it can fill up and be safe across browsers.

So first we will take note of the css which goes something like this:

#footer {
padding: 0 10px;
background:#EEE;
bottom:0px;
right:0px;
left:0px;
position:fixed;
}
#footer p {
margin: 0;
padding: 10px 0;
}

Once again we bring in the four important properties; bottom, left, right, and position. You will also need to change the body tag in the CSS so the footer does not overlap the content you would like the readers to see. This CSS is going to look like this:

body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
background: #666666;
margin: 0;
padding: 0;
text-align: center;
color: #000000;
margin-bottom:50px;
}

And now finally we will look at the HTML to see the footer break out of the container similar to what the header did.

<!– end #container –></div>
<div id=”footer”>
<p>Created by Caleb Jonasson</p>
</div>

Caleb Jonasson

posted by Caleb in CSS, Web Development and have No Comments

Into to HTML: Creating A Basic Web Page

Into to HTML: Creating A Basic Web Page

In order to create your own web page you should first open up a text editor such as notepad or notepad ++. First things first is to copy the following code into your text editor and save it as index.php. PHP is a server side programming language which is most commonly used across the web because of its simple integration with html. Actual PHP code requires a server but if there is html text inside of a PHP file a simple test on your computer will allow you to properly view the page.

<!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>Demo Website || featured on codewithdesign.com</title>
</head>

<body>
<h1>H1 tags</h1>
<h2>H2 tags</h2>
<h3>H3 tags</h3>
<p>The h1 stands for header1 and these p tags are paragraph tags</p>
</body>
</html>

Now we are going to step through the code so you know exactly what is going on and how the web browser reads the information. The top line of the code will let your browser know what standards it is to follow when reading the code.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

The second line of code states that it is going to follow the w3 standards.

<html xmlns=”http://www.w3.org/1999/xhtml”>

Now we are going to get into the more customizable areas of the website. This section of information is known as head information and is not displayed on the webpage itself. This information is once again read by the browser but you can tell the search engines what information to display along with the title of the page. There are many more things that you can do with this section of the text which I will be going over in another into to HTML article.

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Demo Website || featured on codewithdesign.com</title>
</head>

The first bit of the code is very boring but now we can get more into the content of the page. As you can see there are greater and lesser then signs with content in between, these are called tags. When declaring information inside of a tag you need to have a starting tag and a closing tag. The closing tag is going to allow you to specify that it is closing and will always close the tag immediately before it. For every opening tag you need to have a closing tag or information will not be displayed properly.

<h1>H1 tags</h1>
<h2>H2 tags</h2>
<h3>H3 tags</h3>

Notice how these tag examples are within the body tags. This means that the following content will be displayed within the body of the web browser. When you look at the page you will notice that it breaks into sections. The main section is html which contains the sub sections of head and body.

<html>
<head>
</head>
<body>
</body>
</html>

You can start creating a site with just this information but it is a good idea to clarify the beginning information in the tags for the best results when trying to find bugs and errors.

Within the body of the page a lot of the information can be sorted into different sections. In order to seperate the content you will need to use something called div tags. A div tag can easily break apart seperate sections of the page and will help you style your page in the future.

<div id=”header”>
<h1>The Empty Headed Blog</h1>
</div>

Note that it is possible to contain divs inside of divs.

posted by Caleb in Web Development and have No Comments

Going Through Website Creation Part 1: Layout

Going Through Website Creation Part 1: Layout

Starting Up An Old Project

A few months ago I posted an old project on the old blog. The project was entitled “Browser Friendly Feed Reader.” This project consisted of three simple pages. The first was the submitting form where users could enter their rss or xml feed. The contents of this feed could be output in the web browser to displaying it inside of the site framework that was created.

rss_skorg_atchison

Process.php
Forum.php
View.php

The site was very simple but it was more built for the idea behind viewing a feed in the browser. Since then I wanted to create a more advanced version of the site that relied on a database and the ability to subscribe to the feeds. This is when I decided to restart to the old project and completely rework how everything is set from the ground up.

Working With The Framework

framework

When starting to create a new project or just recreating one the first thing that you will need is a frame work. The frame work is a quick drawing of how you would like to have everything setup. Some people like to create theirs with programs such as In Design or Illustrator but I prefer to use a graphing set, a notepad and whatever pen is closest to me. I should be using pencil but I normally have a plan in my head prior to starting something.

dreamweaver_create_a_page

Once you have the general idea of how things are going to work it is a good idea to draw out how you would like to store the key components of a site. I use a notepad throughout the whole process and it usually starts with me laying out something that looks like this.

Contents of index

Header (include not secure page)
Main image
Nav bar (include)

Sidebar (include)
Sidebar components (include single and double width items)
Navigation (include)

Main content (not included)
Post data

Footer (include)
Blocks of meta and links (include)
Bottom strip (include)

Order of Operations When Designing the Index

Once this has been worked up I then head into Adobe Dreamweaver to begin the process of changing my framework into an actual css ready site with all of the divs. This process takes a fair amount of time and the content usually created in this order. First note that Dreamweaver automatically creates the untitled.php page and the css page. At this point I only have the two items on my testing server. Back to showing you the order of operations.

  1. Change the CSS page to create the proper widths for main content, sidebar, and post.
  2. Change padding properties, select fonts, change margin properties.
  3. Create the divs within the untitled document ie the divs in the header that hold link menus.
  4. Add the div id and classes to the CSS file. (remember to work down the content as it appears within your page. Start with the header then go to sidebar, etc.)
  5. Create and fill the pages with fake content and see if this is how you would like the pages to be displayed.
  6. Go through and tweak anything that makes you unhappy.

Pulling Apart the Index.php Page

Now that you have created your base index page and you are somewhat happy with the content you can go ahead and begin to pull the page apart. This is where the layout of includes will come in handy. This process consists of cutting and pasting section of code into new php files. The naming of these files is up to you but I normally go with “pt_” as a prefix for “Part” which is a part of a page and “pg_” which stands for “Page” meaning that it is a whole page. An example of this is “pg_authors.php” or pg_feeds_addfeed.php” The next section of naming a page comes from the actual section that is within the page. On the friendly browser feed viewer project I started there are sections of pages that relate to feeds. If I wanted to create a page where users could subscribe to a feed I would name it “pg_feed_subscribe” this tells me what the php file is, its subject and what the page is for. Another type of file I often contain is the prefix “process_” This is a page that requires a form to post to or backend piece of date. The page naming is completely up to you I just wanted to share how I go about naming my webpages.

Now we will go through pulling the pages apart. Now that we have gone through a little lesson on proper page names it is now time to actually pull something apart. For this I will not be using the rss.skorg.org site but a new site with no content instead.

Here is the full index.php page that we will be working with.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<!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>Test</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<!--[if IE 5]>
<style type="text/css">
/* place css box model fixes for IE 5* in this conditional comment */
.twoColFixRtHdr #sidebar1 { width: 220px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.twoColFixRtHdr #sidebar1 { padding-top: 30px; }
.twoColFixRtHdr #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]--></head>
<body>
<div id="container">
<div id="header">
<h1>Header</h1>
<!-- end #header --></div>
<div id="sidebar1">
<h3>Sidebar1 Content</h3>
<p>The background color on this div will only show for the length of the content. If you'd like a dividing line instead, place a border on the right side of the #mainContent div if it will always contain more content. </p>
<p>Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu, pellentesque  eget, cursus et, fermentum ut, sapien. Fusce metus mi, eleifend  sollicitudin, molestie id, varius et, nibh. Donec nec libero.</p>
<!-- end #sidebar1 --></div>
<div id="mainContent">
<h1> Main Content </h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at,  odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce  varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id,  libero. In eget purus. Vestibulum ut nisl. Donec eu mi sed turpis feugiat  feugiat. Integer turpis arcu, pellentesque eget, cursus et, fermentum ut,  sapien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh.  Donec nec libero.</p>
<h2>H2 level heading </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>
<!-- end #mainContent --></div>
<!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --><br />
<div id="footer">
<p>Footer</p>
<!-- end #footer --></div>
<!-- end #container --></div>
</body>
</html>

Now we are going to pull this page apart and change some things so the include will work properly. The first thing we are going to want to do is change how the header information is setup. We want the content that can be thrown into one file to stay at the very top. The rest that we need for the page is going to be below that.

1
2
3
4
5
6
7
<title>Test</title>
</head>
<body>
<div id="container">
<div id="header">
<h1>Header</h1>
<!– end #header –></div>

Take note of where this section of code is and what has changed. The title tags have been moved below the IE exceptions. This is so it is not included in the new “pt_head_req_top.php” file. Now we are going to cut the bottom part of the header code will have a separate required field for the transition tags. This is important so if you wanted to add class to the divs you could do it to everything based on one file change.

1
2
3
<?php include('pt_head_req_top.php'); ?>
<title>Test</title>
<?php include('pt_head_main.php'); ?>

Inside the two sections is where you want the head data that will change for each page. The following code is what pt_head_main.php consists of.

1
2
3
4
5
6
</head>
<body>
<div id="container">
<div id="header">
<h1>Header</h1>
<!-- end #header --></div>

Because we are now pulling sections of the page together with php the load times will be a little bit quicker and we have decreased the code of the index by an incredible amount. The index.php code now looks like this when we are done with it.

1
2
3
4
5
6
7
8
9
10
11
<?php include('pt_head_req_top.php'); ?>
<title>Test</title>
<?php
include('pt_head_main.php');
include('pt_sidebar_main.php');
?>
<h1> Main Content </h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at,  odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce  varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id,  libero. In eget purus. Vestibulum ut nisl. Donec eu mi sed turpis feugiat  feugiat. Integer turpis arcu, pellentesque eget, cursus et, fermentum ut,  sapien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh.  Donec nec libero.</p>
<h2>H2 level heading </h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam,  justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam  ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo  porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis  ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean  sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.</p>
<?php include('pt_footer_main.php');?>

Now you should be able to create a site that is fully based off of your index. If you need to change things around like the css link based on different pages there is always PHP code for things like that.

Continue on to read part 2

By: Caleb Jonasson

posted by Caleb in CSS, Web Development, php and have Comments (2)

Into to HTML: Creating A Basic Web Page

Into to HTML: Creating A Basic Web Page

In order to create your own web page you should first open up a text editor such as notepad or notepad ++. First things first is to copy the following code into your text editor and save it as index.php. PHP is a server side programming language which is most commonly used across the web because of its simple integration with html. Actual PHP code requires a server but if there is html text inside of a PHP file a simple test on your computer will allow you to properly view the page.

<!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>Demo Website || featured on Code With Design</title>
</head>

<body>
<h1>H1 tags</h1>
<h2>H2 tags</h2>
<h3>H3 tags</h3>
<p>The h1 stands for header1 and these p tags are paragraph tags</p>
</body>
</html>

Now we are going to step through the code so you know exactly what is going on and how the web browser reads the information. The top line of the code will let your browser know what standards it is to follow when reading the code.

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

The second line of code states that it is going to follow the w3 standards.

<html xmlns=”http://www.w3.org/1999/xhtml”>

Now we are going to get into the more customizable areas of the website. This section of information is known as head information and is not displayed on the webpage itself. This information is once again read by the browser but you can tell the search engines what information to display along with the title of the page. There are many more things that you can do with this section of the text which I will be going over in another into to HTML article.

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Demo Website || featured on Code With Design</title>
</head>

The first bit of the code is very boring but now we can get more into the content of the page. As you can see there are greater and lesser then signs with content in between, these are called tags. When declaring information inside of a tag you need to have a starting tag and a closing tag. The closing tag is going to allow you to specify that it is closing and will always close the tag immediately before it. For every opening tag you need to have a closing tag or information will not be displayed properly.

<h1>H1 tags</h1>
<h2>H2 tags</h2>
<h3>H3 tags</h3>

Notice how these tag examples are within the body tags. This means that the following content will be displayed within the body of the web browser. When you look at the page you will notice that it breaks into sections. The main section is html which contains the sub sections of head and body.

<html>
<head>
</head>
<body>
</body>
</html>

You can start creating a site with just this information but it is a good idea to clarify the beginning information in the tags for the best results when trying to find bugs and errors.

Within the body of the page a lot of the information can be sorted into different sections. In order to seperate the content you will need to use something called div tags. A div tag can easily break apart seperate sections of the page and will help you style your page in the future.

<div id=”header”>
<h1>Code With Design</h1>
</div>

Note that it is possible to contain divs inside of divs.

Caleb Jonasson

posted by Caleb in Web Development and have No Comments