...

View Full Version : difference between...



Laharl1234
07-11-2008, 02:11 PM
What's the difference between using for example p {text-align: center} in <head> and <p style="text-align=center"></p> in <body> ??

jerry62704
07-11-2008, 02:14 PM
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.

jcdevelopment
07-11-2008, 02:33 PM
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.

rzea
07-11-2008, 03:12 PM
... and <p style="text-align=center"></p>...
Actually your syntax is incorrect, is:

<p style="text-align:center"></p>

Laharl1234
07-11-2008, 04:25 PM
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?

jcdevelopment
07-11-2008, 04:28 PM
but you can define certain elements by themselves.

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


.style {
css...
}

a selector(this will define all tags that are <p>


p {
css...
}

jerry62704
07-11-2008, 07:14 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum