Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-24-2004, 05:36 PM   PM User | #1
chamith7
New Coder

 
Join Date: Jan 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
chamith7 is an unknown quantity at this point
Post CSS trouble

My website uses CSS (kind of) that someone else wrote for me.

<STYLE TYPE="text/css">
<!--
p
{
text-indent:27px; font:9pt verdana
}
//-->
</STYLE>

and then my website's body has something like:

<FONT blah blah blah>

<B>THE INCIDENT INCIDENT</B> - 24 January 2004
<P>I ran into an old friend at the store yesterday, but he didn't appreciate my clumsiness very much.</P><BR>

<B>THE DAYDREAMING INCIDENT</B> - 23 January 2004
<P>I daydream a lot. Because of this I sometimes have trouble focusing on ...</P><BR>

</FONT>


But the problem is I use CSS for the paragraphs, but I want to boldify and make the titles the font I want, and I guess it is bad html to a <P> tag inside my <FONT> tags (which are for the titles). So in order to have the titles in a font and size that I want, I would have to use a font tag on every single one which would be a big waste. Can someone tell me how I could just have like 2 styles (I guess it'd be called) one for the paragraphs and one for the titles. My website is at http://www.geocities.com/chamith7 if that will help you see what I am talking about. Thanks a lot in advance.
chamith7 is offline   Reply With Quote
Old 01-24-2004, 06:59 PM   PM User | #2
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,549
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there chamith7,

Try it like this, css...
Code:
<style type="text/css">
<!--
p
   {
    text-indent:27px; 
    font:9pt verdana
   }
h1,h2, h3
   {
    font-family:arial;
    color:#000080;
   }
span
   {
    font-family:couier;
    font-size:12px;
    color:#000000;
   }
//-->
</style>
and the body...
Code:
<h1>THE INCIDENT INCIDENT<span>-24 January 2004</span></h1> 
<p>I ran into an old friend at the store yesterday, but he didn't appreciate my clumsiness very much.</p>
<h2>THE DAYDREAMING INCIDENT<span>-23 January 2004</span></h2> 
<p>I daydream a lot. Because of this I sometimes have trouble focusing on ...</p>
<h3>AND THIS IS H3<span>-22 January 2004</span></h3>
cthead
coothead is offline   Reply With Quote
Old 01-24-2004, 07:01 PM   PM User | #3
lavalamp
Regular Coder

 
Join Date: Aug 2003
Location: Loughborough University
Posts: 427
Thanks: 0
Thanked 0 Times in 0 Posts
lavalamp is an unknown quantity at this point
Sure thing, for the titles you should use header tags; h1, h2, h3, h4, h5, h6.

In this case I'll use h2 tags since you should have a page title in an h1 tag, even if it's just something like <h1>Welcome</h1>. Anyway, here's some code:

Code:
<style type="text/css"><!--

h2{font:10pt "verdana", sans-serif;}

p{text-indent:27px;font:9pt "verdana", sans-serif;}

--></style>

</head>

</body>

<h2><b>THE INCIDENT INCIDENT</b> - 24 January 2004</h2>
<p>I ran into an old friend at the store yesterday, but he didn't appreciate my clumsiness very much.</p><br>

<h2><b>THE DAYDREAMING INCIDENT</b> - 23 January 2004</h2>
<P>I daydream a lot. Because of this I sometimes have trouble focusing on ...</p><br>
Just so you know, your entire page could be converted, quite easily, to a CSS and <div> based layout. Since it would be so easy it would be a good place for you to start learning CSS and XHTML if you have a little time. CSS is really easy to get the hang of and XHTML isn't that different to normal HTML.
__________________
AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
BFG GeForce 6800 Ultra OC 256Mb
3 * Kingston 256Mb PC3200 DDR400
Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150
lavalamp is offline   Reply With Quote
Old 01-24-2004, 07:18 PM   PM User | #4
lavalamp
Regular Coder

 
Join Date: Aug 2003
Location: Loughborough University
Posts: 427
Thanks: 0
Thanked 0 Times in 0 Posts
lavalamp is an unknown quantity at this point
Hi coothead, if he were to use a new header element for each of his topics, he would quickly run out of them, have you seen his page?

Headers are for conveying page structure to non-visual browsers, the code you have posted rates the first topic more important than the second, and the second more important than the third etc. But they are all equally important and therefore should all use the same header tag. Some W3C guidence - http://www.w3.org/TR/WAI-WEBCONTENT-...gical-headings.
__________________
AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
BFG GeForce 6800 Ultra OC 256Mb
3 * Kingston 256Mb PC3200 DDR400
Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150
lavalamp is offline   Reply With Quote
Old 01-24-2004, 07:37 PM   PM User | #5
chamith7
New Coder

 
Join Date: Jan 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
chamith7 is an unknown quantity at this point
Thanks a lot

Wow, thank you both very much. I'll get on learning that stuff soon.
chamith7 is offline   Reply With Quote
Old 01-24-2004, 08:18 PM   PM User | #6
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,549
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there lavalamp,
Quote:
Hi coothead, if he were to use a new header element for each of his topics,
he would quickly run out of them, have you seen his page?
You are jesting of course
I did not suggest that chamith7 should use multiple headers for his layout but....
just displayed examples of a tag; of which I presumed, he was unaware

cthead
coothead is offline   Reply With Quote
Old 01-25-2004, 12:30 AM   PM User | #7
lavalamp
Regular Coder

 
Join Date: Aug 2003
Location: Loughborough University
Posts: 427
Thanks: 0
Thanked 0 Times in 0 Posts
lavalamp is an unknown quantity at this point
That bit was a joke yes, but your code did imply that a new header tag should be used for each new topic.
__________________
AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
BFG GeForce 6800 Ultra OC 256Mb
3 * Kingston 256Mb PC3200 DDR400
Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150
lavalamp is offline   Reply With Quote
Old 01-25-2004, 03:14 AM   PM User | #8
suppaman
New Coder

 
Join Date: Jan 2004
Location: Malaysia
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
suppaman is an unknown quantity at this point
I am reading this thread too. I think lavalamp's code is more efficient.
suppaman is offline   Reply With Quote
Old 01-25-2004, 04:27 AM   PM User | #9
chamith7
New Coder

 
Join Date: Jan 2004
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
chamith7 is an unknown quantity at this point
What is "CSS and <div> based layout?"

I read the CSS and XHTML tutorials at w3schools.com and never saw anything about <div>. Where can I learn how to use it on my site?
chamith7 is offline   Reply With Quote
Old 01-25-2004, 09:49 AM   PM User | #10
me'
Senior Coder

 
Join Date: Nov 2002
Location: Warwickshire, England
Posts: 1,229
Thanks: 0
Thanked 0 Times in 0 Posts
me' is an unknown quantity at this point
Quote:
Originally posted by lavalamp
That bit was a joke yes, but your code did imply that a new header tag should be used for each new topic.
I'm sure what he meant was more like this:
Code:
<h1>Chaddy's Journal</h1>
<h2>Fresh from the Cortex</h2>

<h3><span>The Collision Incident</span> - 25 January 2004</h3>
<p>I ran into an old friend at the store yesterday, but he didn't appreciate my clumsiness very much.</p>

<h3><span>The Daydreaming Incident</span> - 24 January 2004</h3>
<p>I daydream a lot. Because of this I sometimes have trouble focusing on ...</p>

...
__________________
David House - Perfect is achieved, not when there is nothing left to add, but when there is nothing left to take away. (Antoine de St. Exupery).
W3Schools | XHTML Validator | CSS Validator | Colours | Typography | HTML&CSS FAQ | Go get Mozilla Now | I blog!
me' is offline   Reply With Quote
Old 01-25-2004, 09:59 AM   PM User | #11
dragon
New Coder

 
dragon's Avatar
 
Join Date: May 2003
Location: Florida
Posts: 99
Thanks: 0
Thanked 0 Times in 0 Posts
dragon is an unknown quantity at this point
http://www.designplace.org/tutorials.php?page=1&c_id=24 and many other sites available through Google search.
__________________
http://www.dragonshobbies.com
dragon is offline   Reply With Quote
Old 01-25-2004, 12:49 PM   PM User | #12
rmedek
Senior Coder

 
Join Date: Nov 2003
Location: Minneapolis, MN
Posts: 2,879
Thanks: 2
Thanked 65 Times in 56 Posts
rmedek is on a distinguished road
Hi chamith7,

"boldify"????

Think of a <div> as just that, a division of the page, and it starts to make more sense. For example...
Code:
<div id="intro">
<p>A well-written introduction, blah blah blah, yakety schmackety...</p>
</div>
<div id="maincontent">
<p>The main content, blah blah blah...</p>
</div>
... you get the point. Then in your CSS you can specify layout for each of those divisions and style your page. Hope this helps,

Rich
__________________
drums | web
rmedek is offline   Reply With Quote
Old 01-25-2004, 01:27 PM   PM User | #13
lavalamp
Regular Coder

 
Join Date: Aug 2003
Location: Loughborough University
Posts: 427
Thanks: 0
Thanked 0 Times in 0 Posts
lavalamp is an unknown quantity at this point
me' I think you're right there, that would make a lot more sense, and conform to the WCAG which is always good .

chamith7, div and span tags do absolutely NOTHING to what is inside them which is why they're so useful. The difference between them is that span is inline (will stay on a line with other in-line content) and div is a block level element (will always push itself onto a new line and expand to as wide as it can).

The real use of div and span tags is when you apply CSS to them, since they have no rules of they're own except for display:block; or display:inline; you can code away without worrying about other predefined rules getting in the way.
__________________
AMD Athlon "Barton" XP 3200+ (11*200.5MHz = 2.2GHz)
BFG GeForce 6800 Ultra OC 256Mb
3 * Kingston 256Mb PC3200 DDR400
Seagate Barracuda 120Gb Ultra ATA-100 and Seagate Barracuda 160Gb, SATA-150
lavalamp is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:41 PM.


Advertisement
Log in to turn off these ads.