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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 29
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts

    body { margin: 0px; padding: 0px; }

    <style>
    body { margin: 0px 0px 0px 0px; padding: 0px; }
    </style>

    Is this usefull at all or is it default ?
    Shawn

  • #2
    giz
    giz is offline
    Regular Coder
    Join Date
    Apr 2003
    Location
    UK
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah it is useful, as it replaces a load of browser specific HTML tags and attributes that people usually use.

    Run any site you like through http://validator.w3.org/detailed.html and you will find many that have a whole load of error messages like:

    marginwidth is not a valid attribute and so on.

    That CSS removes those errors. Use it!.



    The four margin errors can be replaced with a little bit of CSS code instead. Put this is a text file, with a name ending in .css:

    body {
    margin: 0px;
    padding: 0px;
    }




    In CSS you must have units with all of your numbers, so one of either px, pt, em, %, or # is always required.


    You should export the CSS to an external file and call it with a one line instruction in the <head> section:
    <link type="text/css" rel="stylesheet" src="/path/file.css">

    External CSS files must not contain any HTML tags or code.

  • #3
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by giz
    Put this is a text file, with a name ending in .css:
    As long as the <link> has type="text/css" in it, the extension is irrelavent as the MIME type is what is needed, I always use .css too for good practice tho.

    Yes it's useful if you want it.

    margin:0px 0px 0px 0px; will take care of each side of the element, starting from the top going clockwise, if all values are zero, you may as well just use margin:0px;.

    Moderator: General web building

    Get out from under them, resist and multiply.
    Get out from under precipice and see the sky.

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    So it IS necessary that I use these styles?
    Shawn

  • #5
    Senior Coder
    Join Date
    Jul 2002
    Posts
    1,628
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No, of course not.
    In an HTML document, CSS is never necessary.
    You would use it only if you wanted to remove the margin/padding.

    Moderator: General web building

    Get out from under them, resist and multiply.
    Get out from under precipice and see the sky.

  • #6
    giz
    giz is offline
    Regular Coder
    Join Date
    Apr 2003
    Location
    UK
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You should use the CSS codes in place of the browser specific HTML codes for marginwidth and marginhelight and so on, assuming that you have that HTML on your site.

    Run your site through the code validator. If you see a whole load of errors relating to margins then that new piece of code is just for you.

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if the value is 0 you don't need a unit:

    margin:0;
    padding:0;

    is fine. Personally, I always use this - even if I do want body margins, it's much easier to specify them as margins or padding of internal elements, I find. And this way you can have your navigation strip run the full width of the page while main content is padded.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #8
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Originally posted by giz
    Run your site through the code validator.

    How?
    Shawn

  • #9
    giz
    giz is offline
    Regular Coder
    Join Date
    Apr 2003
    Location
    UK
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #10
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Each time I try that it doesn't work

    http://validator.w3.org/check?uri=http%3A%2F%2Fwww.perdu.com&charset=%28detect+automatically%29&doctype=Inline&verbose=1
    I was not able to extract a character encoding labeling from any of the valid sources for such information. Without encoding information it is impossible to validate the document. The sources I tried are:

    The HTTP Content-Type field.
    The XML Declaration.
    The HTML "META" element.
    And I even tried to autodetect it using the algorithm defined in Appendix F of the XML 1.0 Recommendation.

    Since none of these sources yielded any usable information, I will not be able to validate this document. Sorry. Please make sure you specify the character encoding in use.

    IANA maintains the list of official names for character sets.
    That's what it ALWAYS says, I don't understand It's just a little simple site:

    Code:
    <HTML>
    <HEAD>
    <TITLE>
    Vous Etes Perdu ?
    </TITLE>
    </HEAD>
    <BODY>
    <H1>Perdu sur l'Internet ?</H1>
    <H2>Pas de panique, on va vous aider</H2>
    <STRONG><PRE>    * <----- vous &ecirc;tes ici</PRE></STRONG>
    </BODY>
    </HTML>
    (That's not my site btw)
    Shawn

  • #11
    New Coder
    Join Date
    Aug 2002
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think you are looking for this:


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

  • #12
    giz
    giz is offline
    Regular Coder
    Join Date
    Apr 2003
    Location
    UK
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For your page to actually be valid you MUST declare the character encoding used for the page, with something like:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    There are also other schemes such as UTF-8 and many others,





    It is also a good idea to declare what language the page is in, using:

    <meta http-equiv="Content-Language" content="EN-GB">

    The language and country codes come from ISO 4217 and ISO 3166.





    You do need the meta description tag, and it is useful but not vital to have a meta keywords tag:

    <meta name="Description" content=" Your Description Here. ">
    <meta name="Keywords" content=" your, keyword, list, here ">






    Your document should begin with a !DOCTYPE and a title element:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title> Your Title Here </title>






    The last parts of your header should have your links to external style sheets and external javascript files:

    <link type="text/css" rel="stylesheet" src="/path/file.css">

    <script type="text/javascript" language="javascript" src="/path/file.js"></script>

    </head>
    <body>





    .
    Last edited by giz; 06-10-2003 at 11:40 PM.

  • #13
    Senior Coder
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    1,063
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Does all that do anything else than make the validator work?
    Shawn

  • #14
    Senior Coder
    Join Date
    Mar 2003
    Location
    OHIO
    Posts
    1,438
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Good question!!!

    I know that when I put the doc type at the top of some of my pages that have scripts in them the scripts seem to no longer function in IE 5.1.6 for MAC and they get a little weird in Netscape 4.76 for Mac as well.

    Can't wait to hear the answer to this one.

    MNS
    Last edited by MotherNatrsSon; 06-11-2003 at 01:32 AM.

  • #15
    giz
    giz is offline
    Regular Coder
    Join Date
    Apr 2003
    Location
    UK
    Posts
    226
    Thanks
    0
    Thanked 0 Times in 0 Posts
    These bits are required by the validator, but they are also required by the user's browser as well:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">




    The <title> is also required by the browser, and is most important to the search engines.



    The meta description (and sometimes the meta keywords too) as well as the meta Content-Type are required by search engines. The language tag becomes important in online translation tools and in some search engines.




    Use all of that code then you know that you have covered every angle: validator, browsers, users, search engines.
    Last edited by giz; 06-11-2003 at 01:28 AM.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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