Posts Tagged ‘Css File’

ADDING SOME CSS TO OUR WEBSITE (MFW#5)

Wednesday, July 29th, 2009

“My First Website” array navigation: first postwhole series

0a170 css baby Adding some CSS to our website (MFW#5)It’s time for the impulse you’ve all been watchful for: adding CSS to the website! In the previous post in this array we eventually were equates to to get the little unequivocally simple calm upon the initial website. Unfortunately, as distant as websites go, it’s flattering sore — no styling, no colors, as good as what we got was the single prolonged liquid layout (a blueprint whose breadth varies with the breadth of the browser window.)

So hurl up your sleeves, get Notepad, TextEdit, or your the a single preferred text-digesting program ready to go, since we’re gonna supplement the little CSS!

Adding an External Style Sheet

The initial thing we need to do is begin the vacant request in possibly Notepad or TextEdit. You’re starting to name this record “style.css” (without the quotes) as good as save it in the same printed matter with the “index.html” record we combined in the prior post. (Design Projects – My First Website – website.)

The fixing of this record isn’t unequivocally which important. You can call it “mainsheet.css” or “stylesheet.css” or even “frankie.css” if which your preference. The usually thing we MUST have is the “.css” during the end. Also, don’t have have have use of of of spaces or upper-case letters. Instead of spaces, we can have have have use of of of the lurch ( – ) or an underscore ( _ ). For example: “style_version1″.css” Make certain to save it as the UTF-8 as we schooled in the previous post.

Linking your web page to the outmost CSS file

Next, we’re starting to couple the web page to the CSS record we only created. We do so regulating this line of symbol up:

<link rel="stylesheet" href="style.css" type="text/css">

Now, open your “index.html” as good as supplement which line of symbol up anywhere in between the <head> </head> tags. Like this: (I done it red to have it simpler to spot.)

<head>
<title>My First Website</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" href="style.css" type="text/css">
</head>

Wrapping the web page

It’s time to supplement the initial “box” to the web page. This box will ring or “wrap” the total page itself. We will do so by adding <div> </div> tags. But prior to we do that, we need to name the <div> so we can have have have use of of of the CSS record to shift how it will appear.

To name this <div>, we’re starting to give it the singular id. “Id”s can have any name during all, only have certain it is detailed sufficient to we so we know what is does. For example, this <div> is starting to hang the web page, so let’s give it an id with the name of “pagewrap”. And we write it similar to this:

<div id="pagewrap">

Now supplement both the opening tab as good as the shutting tab to your “index.html” file. See subsequent (to have it shorter, we left out all of the calm we combined in the previous post.)

<body>

<div id="pagewrap">

<h1>A Level 1 Heading</h1>
(Here’s all the calm from before)

</div>
</body>

Save your “index.html” file.

Finally! Some CSS!

Go behind to your “style.css” record as good as come in (or duplicate as good as paste) the following:

#pagewrap {
width: 800px;
}

What this does is acknowledgement which the id called “pagewrap” (the # pointer equates to “id” in CSS lingo) will have the breadth of 800px (the “px” equates to pixels.) The opening as good as shutting curly brackets — { } — contingency approximate the CSS code!

Save your “style.css” file.

Take the look

If all went well, afterwards when we perspective your “index.html” record in your browser (remember how to do that?) It should demeanour similar to this:

View the web page

If your web page looks similar to the a single on top of afterwards congratulations! If not, go behind an check all of the formula as good as symbol up for mistakes. Here is the full symbol up of the “index.html” record for we to review against:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>My First Website</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link rel="stylesheet" href="style.css" type="text/css">
</head>

<body>

<div id="pagewrap">

<h1>A Level 1 Heading</h1>

<p>Morbi non erat non ipsum pharetra tempus. Donec orci. Proin in ante. Pellentesque lay amet purus. Cras egestas diam sed ante. Etiam imperdiet urna lay amet risus. Donec ornare arcu id erat.</p>

<p>Aliquam et nisl vel ligula consectetuer suscipit. Morbi euismod enim eget neque. Donec sagittis massa. Vestibulum quis augue lay amet ipsum laoreet pretium. Nulla facilisi. Duis tincidunt, felis et luctus placerat, ipsum libero vestibulum sem, vitae elementum wisi ipsum the metus.</p>

<h3>A Level 3 Heading</h3>

<p>Morbi non erat non ipsum pharetra tempus. Donec orci. Proin in ante. Pellentesque lay amet purus. Cras egestas diam sed ante. Etiam imperdiet urna lay amet risus. Donec ornare arcu id erat.</p>

<p>Aliquam et nisl vel ligula consectetuer suscipit. Morbi euismod enim eget neque. Donec sagittis massa. Vestibulum quis augue lay amet ipsum laoreet pretium. Nulla facilisi. Duis tincidunt, felis et luctus placerat, ipsum libero vestibulum sem, vitae elementum wisi ipsum the metus.</p>

</div>

</body>

Conclusion

We’ve right away taken the liquid layout (a blueprint which changes breadth with the browser window) as good as done it in to the fixed-width layout (a blueprint whose breadth is unblushing by the breadth of the browser window). Still it’s not most to demeanour at, though we’re removing there!

In the subsequent post I’ll intro we to the bloody sum of the CSS box indication by adding the little padding, the little margins, as good as even the limit to approximate the web page.

Until subsequent time!

 Adding some CSS to our website (MFW#5)  Adding some CSS to our website (MFW#5)  Adding some CSS to our website (MFW#5)  Adding some CSS to our website (MFW#5)  Adding some CSS to our website (MFW#5)  Adding some CSS to our website (MFW#5)

 Adding some CSS to our website (MFW#5)

 
 
All Rights Reserved 2009.