|
||||||
| HTML Programming Forum discussion covering HTML, XHTML, DHTML and all flavors of HTML. Hypertext Markup Language is used to create websites. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||||
|
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:
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||||
|
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> Whatever the name of your CSS file is it must have the file extension .css |
|
|||||
|
Quote:
|
|
|||||
|
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> 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> Code:
body {
background-color:#000000;
}
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> Hope it helps, Thanks, Death |
| Sponsored Links |
|
|
|
|||||
|
Interesting how there are so many ways to output the same result.
__________________
Funny Stories and Humorous Pictures |
|
|||||
|
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> Code:
<head> <link rel="stylesheet" href="Main.css" /> </head> It's cleaner easier to edit, and saves you time and headaches. - Death |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |
| 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 |