SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Evangelist Barnum's Avatar
    Join Date
    Oct 2008
    Posts
    413
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Simple question...

    Why is it possible to set a left margin, but not a right one? Why should this command/code be so difficult? I want to center my text on my site, and it is difficult to do (at least to me).

    I am a neophyte, and have only been working with HTML/CSS for about a year. I find it amazing that the powers to be can make the process so difficult. There seems to be an effort to keep changing things so that the
    newcomer has to constantly change his way of thinking.

    I know the ole saying that "the only thing constant is change" but I often wonder if the folks who manage all this just want to keep their elite status.
    Okay, now shoot me down.

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by Barnum View Post
    Why is it possible to set a left margin, but not a right one?
    That's simply not the case. They work both the same.

    Quote Originally Posted by Barnum View Post
    Okay, now shoot me down.
    You just need to take a bit of time to learn this stuff properly, preferably with a good book. The basics of CSS (including margins) are very simple. So show us a bit of code and we can show you what to do.

    If you are trying to center a div, you can just set a width on it and use a simple rule like

    margin: 0 auto;

    The 0 means zero top and bottom margin, and "auto" left and right margin, which centers the element inside its parent element.

    I know the ole saying that "the only thing constant is change" but I often wonder if the folks who manage all this just want to keep their elite status.
    That's quite simple, and has not changed in over a decade. These are not shifting sands!

  3. #3
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    It is only the marketers that that want you believe the sand has shifted like Ralph said essentially CSS and HTML haven't really changed for over a decade. It's more a case of the browsers and hacks have instead.

  4. #4
    SitePoint Addict AtSea webdesign's Avatar
    Join Date
    May 2010
    Location
    Newark, Delaware
    Posts
    283
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    welcome to the web development world. As with technology web development is constantly evolving.

    Personally I don't think things change so much as improvements are being made.

    Once you understand the basics and have a thorough knowledge of what's going on you will see the light.

  5. #5
    SitePoint Evangelist Barnum's Avatar
    Join Date
    Oct 2008
    Posts
    413
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Just do not want the text running to edge of page on most of my site. Would like decent margins left and right.

    www.stoutstandards.com

  6. #6
    Sploghm bronze trophy Victorinox's Avatar
    Join Date
    Nov 2008
    Posts
    749
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    CSS to use in an external stylesheet to provide a gap of 20px at each side of all your pages.
    Code CSS:
    body {padding-left:20px;padding-right:20px;}
    Or a gap of 20px on all sides
    Code CSS:
    body {padding:20px;}
    Or 20px sides, 0 top and bottom
    Code CSS:
    body {padding:0 20px}
    Pages that are exceptions to the rule can have a class added to the body element. For example:
    Code CSS:
    .something {padding:20px 0;}
    Would leave no gap at the sides and 20px top and bottom. The body element for these pages would be
    Code HTML4Strict:
    <body class="something">
    Your home page uses an external stylesheet but other pages have embedded stylesheets. Are you planning to rework the entire site?

    It's good that your site focuses on content rather than eye candy, but the code is in sore need of straightening out. People prepared to help with specific problems expect there to be a baseline standard that the helpee is targeting, otherwise it's like troubleshooting a metal detector made of bean cans and tooth fillings. The builder's ambition is admirable, but the best solution is to use the right components and follow a blueprint.

  7. #7
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Victorinox View Post
    Your home page uses an external stylesheet but other pages have embedded stylesheets. Are you planning to rework the entire site?
    External AND internal -- with so much internal CSS it begs the question what is that external file even doing?

  8. #8
    SitePoint Evangelist Barnum's Avatar
    Join Date
    Oct 2008
    Posts
    413
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I do not know how to do an external stylesheet any longer. Not an excuse, but at 70 it's all I can do to keep up with what I do know. Hell I can't remember what I had for breakfast!

  9. #9
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by Barnum View Post
    I do not know how to do an external stylesheet any longer.
    You already have one. There's a link to it in the head:

    <link rel="stylesheet" href="styles.css" type="text/css"/>

    So all you need to do is paste your styles into that styles.css file.

    EDIT:

    Ah, I see that link is just on the home page. Assuming all your pages are in the root folder (as they seem to be) you could place that same link in the head of each page and the styles in that one file will apply to each of your pages.

  10. #10
    Non-Member bronze trophy
    Join Date
    Nov 2009
    Location
    Keene, NH
    Posts
    3,760
    Mentioned
    23 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Ah, I see that link is just on the home page. Assuming all your pages are in the root folder (as they seem to be) you could place that same link in the head of each page and the styles in that one file will apply to each of your pages.
    Which is one of the reasons to use CSS -- so you can say the styling of things that are going to be the same on every page (like the menu) just ONCE in one file, and have it pick up on all the pages. Makes it easier to maintain (less code), easier to make sweeping re-stylings (since you only edit it in one place and every page picks it up), and even saves bandwidth and speeds loading of sub-pages since you are basically pre-caching the appearance of your sub-pages.

    Quote Originally Posted by Barnum View Post
    I do not know how to do an external stylesheet any longer. Not an excuse, but at 70 it's all I can do to keep up with what I do know. Hell I can't remember what I had for breakfast!
    I'm only 40, but I know what you mean -- medication induced stroke backed by some nice parkinsonisms thanks to some quackery -- so my short-term memory is a bit wonky.

  11. #11
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Off Topic:

    I was born with faulty short-term memory so when I get older I suspect, I'll be really bad or at least used to the problem with having it all my life.

    Well, keep trying you may retain some of the information maybe you should write yourself notes; that 'external style sheets' are good and internal are bad and print out some code snippets.


Bookmarks

Posting Permissions

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