CSS Basics tutorial #2

Post all your tuts or request for tuts here.
User avatar
rockinliam
Posts: 466
Joined: Sun Jun 07, 2009 11:26 am

CSS Basics tutorial #2

Post by rockinliam »

Welcome back to Rockinliam's Basic CSS tutorial.
The objective of this tutorial is to get some styled text into our webpage.

Part One: HTML

First we must have some text to work with so open up our index.html.

Within the content div insert:

Code: Select all

<p>This is some text that will be styled. </p>


If you are unsure what the outcome will look like i will so you now:

Code: Select all

<html>
<head>
<title>Basic CSS Tutorial</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrapper">
	<div class="banner">
    </div>
    <div class="sidebar">
    </div>
    <div class="content">
    <p>This is some text that will be styled. </p>
    </div>
</body>
</html>
That is all we need to do for now in our HTML. If you load it up into your browser it should have some rather ugly text inside of it.

Part Two: Styling the text.

We must now give this text a style. So go ahead and open up your style.css. Insert this:

Code: Select all

.content p{
                margin-top:20px
	margin-left:20px;
	margin-right:20px;
	font:Verdana, Arial, Helvetica, sans-serif;
}
We have styled any paragraphs that is within our content area. Paragraphs are defined with the <p> tag. I have given it margins both left and right, and also on top. I have styled the font too with the "font:" tag.

Load up your index.html and the text should now have margins.

The end of part two of my basic css tutorial.
Skillset: C/C++, OpenGL, C#, Lua, PHP, MySql, Web Dev etc.
Website: https://liam-griffiths.co.uk/
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS Basics tutorial #2

Post by Jackolantern »

Thanks! CSS seems like such secret black arts to me lol. Just like chess, it is one of those "a little while to learn, a lifetime to master" kind of things lol
The indelible lord of tl;dr
User avatar
rockinliam
Posts: 466
Joined: Sun Jun 07, 2009 11:26 am

Re: CSS Basics tutorial #2

Post by rockinliam »

Tbh the basics are pretty straightforward, and most people pick up the groundwork quite fast although, to alot of people CSS does seem like a dark art but once you get it out into the light it turns out it isn't scary at all, in fact its rather forgiving in terms of a learning curve. So definitely like chess in terms of learning the tricks and the best way to go about achieving your goal. :)
Skillset: C/C++, OpenGL, C#, Lua, PHP, MySql, Web Dev etc.
Website: https://liam-griffiths.co.uk/
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS Basics tutorial #2

Post by Jackolantern »

Thanks again for the tutorials. I have been learning a bit more about CSS recently, and have a quick question. I have seen in some CSS tutorials that some fonts are listed in double-quotes, like "Palatino Linotype", whereas others, like Baskerville, are not. What is the difference, and why do some seem to go in double-quotes?

EDIT: I may have figured it out on my own by finding a couple other examples, but is it because they the fonts in double-quotes are two words?
The indelible lord of tl;dr
User avatar
Chris
Posts: 1581
Joined: Wed Sep 30, 2009 7:22 pm

Re: CSS Basics tutorial #2

Post by Chris »

How can you make a user friendly website without CSS? I'm guessing you're another one of those idiots who use tables for everything.. Tables are made for listing information.

Anyway, the double quotes are because there is a space in the name of the font, but it is better to just stick to normal fonts like, Arial, and Times New Roman when making a website anyway.

I find if you want to learn CSS the best way is to get Adobe Dreamweaver, or maybe Go Live, you could get an old portable version of that quite easy I'm sure, only be ware of viruses.

EDIT: @liam, You should be giving your xHTML a doc type, otherwise things like margins might not work properly in older browsers, I would actually be surprised if they worked in newer ones..
http://www.w3schools.com/Xhtml/xhtml_dtd.asp
Fighting for peace is declaring war on war. If you want peace be peaceful.
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: CSS Basics tutorial #2

Post by hallsofvallhalla »

tables are a choice not a mark of intelligence or even lack thereof.
Falken
Posts: 438
Joined: Fri May 08, 2009 8:03 pm

Re: CSS Basics tutorial #2

Post by Falken »

Chris wrote:I'm guessing you're another one of those idiots who use tables for everything.. Tables are made for listing information.
Calling people idiots is never a good idea, even if they sometimes are. Just makes everyone mad at each other for some reason :shock:

But otherwise you are perfectly correct about tables. Here is how I use them:
http://gamedatabase.eu/?pid=browse

Whole design is Layers (Div) configured with CSS. All data on the other hand is presented in a nice table instead. In my opinion the way tables and divs can be used together in a nice way :)
--- Game Database ---
For all your game information needs!
Visit us at: http://www.gamedatabase.eu today!
User avatar
hallsofvallhalla
Site Admin
Posts: 12026
Joined: Wed Apr 22, 2009 11:29 pm

Re: CSS Basics tutorial #2

Post by hallsofvallhalla »

amen Falken, I have seem some wild things done with Tables and CSS together and to not harp on Chris I understand where he is coming from when people use straight tables and have this lego block looking page :)
User avatar
rockinliam
Posts: 466
Joined: Sun Jun 07, 2009 11:26 am

Re: CSS Basics tutorial #2

Post by rockinliam »

@Jackolantern: Used because of spaces within the name of the font.

@Chris: Table are your only other option seriously, you could use CSS but embed it in the page, but mostly the best way to make a site look pretty is to use a bit of CSS. Though tables are acceptable the biggest flaw is when you decide to change your site you have to rewrite the entire page again. Also the oldest browser i build for is IE6, even tho it is pathetic at CSS.

@Halls: Agreed, tables are a choice and people should pick whatever method suites them and their project best.

My feelings on tables. Should only really be used for tabular data, and possibly for site navigation. Because i find building an entire site with tables takes more time and is less controllable than CSS, that said tables are far more compatible than CSS.

Finally im kinda unsure of what other basic bases I need to cover, ideas?
Skillset: C/C++, OpenGL, C#, Lua, PHP, MySql, Web Dev etc.
Website: https://liam-griffiths.co.uk/
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: CSS Basics tutorial #2

Post by Jackolantern »

Chris wrote:How can you make a user friendly website without CSS? I'm guessing you're another one of those idiots who use tables for everything.. Tables are made for listing information.


Are you talking to me? I don't see how this fits in with any of the other posts in this thread. I never said I have used tables before. I am just learning web design for the first time ever.
The indelible lord of tl;dr
Post Reply

Return to “Tutorials”