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 07-11-2008, 02:11 PM   PM User | #1
Laharl1234
New Coder

 
Join Date: Jul 2008
Posts: 19
Thanks: 5
Thanked 0 Times in 0 Posts
Laharl1234 is an unknown quantity at this point
difference between...

What's the difference between using for example p {text-align: center} in <head> and <p style="text-align=center"></p> in <body> ??
Laharl1234 is offline   Reply With Quote
Old 07-11-2008, 02:14 PM   PM User | #2
jerry62704
Senior Coder

 
jerry62704's Avatar
 
Join Date: Oct 2007
Location: Springfield, IL
Posts: 1,046
Thanks: 9
Thanked 81 Times in 81 Posts
jerry62704 is on a distinguished road
If you put it in a style section in the header, it will affect every "p" tag. If you put it on a specific one in the body, it will only affect that tag and no other.
__________________
.
.
...and gladly would he learn and gladly teach

Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls
jerry62704 is offline   Reply With Quote
Old 07-11-2008, 02:33 PM   PM User | #3
jcdevelopment
Senior Coder

 
jcdevelopment's Avatar
 
Join Date: Oct 2007
Location: Cowboy Nation
Posts: 2,171
Thanks: 173
Thanked 257 Times in 257 Posts
jcdevelopment will become famous soon enoughjcdevelopment will become famous soon enough
Quote:
Originally Posted by Laharl1234 View Post
What's the difference between using for example p {text-align: center} in <head> and <p style="text-align=center"></p> in <body> ??
Also that is known as "inline CSS". It is mostly used as a debugging tool to check problems or find solutions. Its better to define elements in a seperate style sheet outside the HTML file.
jcdevelopment is offline   Reply With Quote
Old 07-11-2008, 03:12 PM   PM User | #4
rzea
New Coder

 
Join Date: Jun 2008
Location: Bradford, OH (30 mins from Dayton)
Posts: 36
Thanks: 1
Thanked 11 Times in 11 Posts
rzea is an unknown quantity at this point
Quote:
Originally Posted by Laharl1234 View Post
... and <p style="text-align=center"></p>...
Actually your syntax is incorrect, is:
Code:
<p style="text-align:center"></p>
rzea is offline   Reply With Quote
Old 07-11-2008, 04:25 PM   PM User | #5
Laharl1234
New Coder

 
Join Date: Jul 2008
Posts: 19
Thanks: 5
Thanked 0 Times in 0 Posts
Laharl1234 is an unknown quantity at this point
Quote:
Originally Posted by jerry62704 View Post
If you put it in a style section in the header, it will affect every "p" tag. If you put it on a specific one in the body, it will only affect that tag and no other.
isn't that what the "class" tag is for though?
Laharl1234 is offline   Reply With Quote
Old 07-11-2008, 04:28 PM   PM User | #6
jcdevelopment
Senior Coder

 
jcdevelopment's Avatar
 
Join Date: Oct 2007
Location: Cowboy Nation
Posts: 2,171
Thanks: 173
Thanked 257 Times in 257 Posts
jcdevelopment will become famous soon enoughjcdevelopment will become famous soon enough
but you can define certain elements by themselves.

a class(this will define all elements with applied class .style

Code:
.style {
css...
}
a selector(this will define all tags that are <p>

Code:
p {
css...
}
jcdevelopment is offline   Reply With Quote
Old 07-11-2008, 07:14 PM   PM User | #7
jerry62704
Senior Coder

 
jerry62704's Avatar
 
Join Date: Oct 2007
Location: Springfield, IL
Posts: 1,046
Thanks: 9
Thanked 81 Times in 81 Posts
jerry62704 is on a distinguished road
There is no "class" tag. Class is part of most tags (an attribute). You do not need to use one unless you want to. For example:
<style xxx >
p {color:red} // or color:#ff0000 or color:#f00
</style>

<body>
<p>this text is in red</p>
<p style="color:blue">this text is in blue</P
<p>this is also red</P>

will give the colors specified. You could code it like this:
<style ...>
.red {color:red}
</style>
<body>
<p>no color here</p>
<p class="red">red color here</p>
<p>no color again</p>

with all this assuming proper html formatting (style in the <head>, etc).

If you plan on having two or more pages, you would want to have all the styling in an external style sheet included on every page. That way you change something once and it propagates to all the pages.
__________________
.
.
...and gladly would he learn and gladly teach

Visit www.LiberalsWin.com for humor and the unique Bush/Obama Approval Polls
jerry62704 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 09:23 PM.


Advertisement
Log in to turn off these ads.