Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jul 2008
    Posts
    19
    Thanks
    5
    Thanked 0 Times in 0 Posts

    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> ??

  • #2
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts
    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

  • #3
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts
    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.

  • #4
    New Coder
    Join Date
    Jun 2008
    Location
    Bradford, OH (30 mins from Dayton)
    Posts
    36
    Thanks
    1
    Thanked 11 Times in 11 Posts
    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>

  • #5
    New Coder
    Join Date
    Jul 2008
    Posts
    19
    Thanks
    5
    Thanked 0 Times in 0 Posts
    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?

  • #6
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts
    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...
    }

  • #7
    Senior Coder jerry62704's Avatar
    Join Date
    Oct 2007
    Location
    Springfield, IL
    Posts
    1,100
    Thanks
    13
    Thanked 87 Times in 87 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •