Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > HTML Programming

HTML Programming Forum discussion covering HTML, XHTML, DHTML and all flavors of HTML. Hypertext Markup Language is used to create websites.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-08-2007, 12:57 AM
Tyger's Avatar   
Tyger Tyger is offline
Newbie
 
Join Date: Nov 2007
Location: USA
Posts: 2
Rep Power: 0
Tyger is on a distinguished road
Send a message via MSN to Tyger
Default Programming confusion

alright, first off, I wasn't sure which forum to put this in. And since it's my first post I apologize if it's in the wrong place.

I'm building a website, and I know how to use html and css but this is the first site I'm building from scratch. I'm not using dreamweaver, or any software like that. I'm not sure how to use the css in with the html, I tried reading and figure it out but I'm still confused.

The summary is (for those who don't understand my rambling) the whole what goes where and how to put the css onto the page is what's confusing me. despite knowing html and css.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-08-2007, 01:19 AM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,478
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Generally there are three ways you can use CSS:
1) A separate file
2) Defined in the <head> of your html file
3) As a tag attribute

I the third method is going to be depreciated in future versions of XHTML - I'm not sure which method you are asking about, since you want to use "css in with the html" I'm going to assume you mean the third method.

Most tags accept a style attribute, that style allows you to define the style using CSS for that particular element. Example:

html4strict Code:
  1. <img src="../image.png" style="border: 1px solid" />
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-10-2007, 08:55 PM
ETbyrne's Avatar   
ETbyrne ETbyrne is offline
Learning Programmer
 
Join Date: Nov 2007
Location: Lapeer, MI
Posts: 30
Rep Power: 4
ETbyrne is on a distinguished road
Default

The best method is to create a file for the CSS and then link to it in the <head> tags. Like so...

Code:
<head>
<link rel="stylesheet" href="styles.css" type="text/css" />
</head>
This is assuming the file with your CSS in it is called styles.css
Whatever the name of your CSS file is it must have the file extension .css
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-19-2007, 03:55 PM
TcM's Avatar   
TcM TcM is offline
Code Warrior
 
Join Date: Aug 2006
Location: In a technologic world :p
Posts: 8,332
Rep Power: 68
TcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of lightTcM is a glorious beacon of light
Default

Quote:
Originally Posted by ETbyrne View Post
The best method is to create a file for the CSS and then link to it in the <head> tags. Like so...

Code:
<head>
<link rel="stylesheet" href="styles.css" type="text/css" />
</head>
This is assuming the file with your CSS in it is called styles.css
Whatever the name of your CSS file is it must have the file extension .css
Yup, that will even help in future website editing, because if you modify that external file the whole website will be modified.. That's why I love CSS.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 11-23-2007, 02:07 PM
Death Slaught's Avatar   
Death Slaught Death Slaught is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
Death Slaught is on a distinguished road
Default

Like they said, you can put it in as an: Internal or External Style Sheet, or insert the style tag.

Here's and example of Internal style sheets.

HTML Code:
<html>
<!-- Internal Style Sheets go in the head tag -->
<head>

<style type="text/css">
body {
  background-color:#000000;
}
</style>

</head>
</html>
It's a bad example, but you should get the idea.

Here's an example of External Style Sheets:

This is the HTML

HTML Code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="Source" />
</head>
</html>
Now here's the CSS

Code:
body {
  background-color:#000000;
}
External Style Sheets are in seperate documents, with the .css extention.

Now here's an example of inserting the style tag:

HTML Code:
<html>
<body>

<div style="width:200px; height:200px; border:1px solid #000000; position:absolute; left:400px; top:150px;">

</div>

</body>
</html>
External Style Sheets are the easiest to read, and maintain, next would be Internal Style Sheets, and lastly inserting the style tag.

Hope it helps, Thanks, Death
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 11-24-2007, 11:54 AM
DevilsCharm's Avatar   
DevilsCharm DevilsCharm is offline
Programming God
 
Join Date: Jul 2006
Posts: 887
Rep Power: 14
DevilsCharm is on a distinguished road
Default

Interesting how there are so many ways to output the same result.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 11-26-2007, 08:11 AM
Death Slaught's Avatar   
Death Slaught Death Slaught is offline
Newbie
 
Join Date: Nov 2007
Posts: 20
Rep Power: 4
Death Slaught is on a distinguished road
Default

Yes that's both good, and bad. Good because it's not that hard to use, and get the desired output, but bad because:

1. The W3C created CSS to seperate structure(HTML) from style(CSS).
2. Making your CSS Internal/Inserting it with the style tag defeats what the W3C is trying to do. The reason I say this is because it makes the content of your head element extremely messy. Even with endentions, it's just sloppy there's no foundation or organization to using it. Using the style tag is even worse. Your doing exactly what the W3C worked so hard to get rid of.......putting structure with the style of the page.
3. Your more prone to mistakes by using them, because they are so munched together.

External style sheets are the best hands down, you're able to organize them by there file name. For example:

Say you wanted a black border around a white page, you can do it like this:

HTML Code:
<html>

<head>
<style type="text/css">

body {
  background-color:#ffffff;
}

.main {
  width:100%;
  height:100%;
  border:1px solid #000000;
}

</stlye>
</head>

<body>
<div class="main">
</div>
</body>

</html>
or do this:

Code:
<head>
<link rel="stylesheet" href="Main.css" />
</head>
and then put the CSS in another document, named Main.css

It's cleaner easier to edit, and saves you time and headaches.


- Death
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning Programming frank_l C and C++ 11 10-11-2007 03:23 AM
A General Idea about programming feariel General Programming 3 09-12-2007 08:50 AM
Not sure my college is good for Programming marta General Programming 1 08-17-2007 11:13 AM


All times are GMT -5. The time now is 07:22 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads