Results 1 to 7 of 7

Thread: the way css is organized

  1. #1
    Join Date
    Apr 2008
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default the way css is organized

    God Bless You,

    Is css to be written in a certain organized way with scripts starting on the left then kind of moving right or is it ok that they are all left aligned? I know that this is not going to affect the preview of the page, just saying if maybe in the future someone won't like all the code left aligned?

  2. #2
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Most common way of writing CSS

    Code:
    body
    {
    	background: #FFFFFF;
    	color: #000000;
    	font: 10pt verdana, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif;
    	margin: 3px 0 0 0;
    }
    a:link, body_alink
    {
    	color: #333333;
    }
    Ryan
    Sevierville, TN

  3. #3
    Join Date
    Apr 2008
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    that's in the head, but what about in the body?

  4. #4
    Join Date
    Apr 2006
    Posts
    190
    Thanks
    3
    Thanked 7 Times in 7 Posts

    Default

    Then left to right

    Code:
    style="margin-bottom:3px; border-bottom-width:0px; width:100%; text-align:left"
    Ryan
    Sevierville, TN

  5. #5
    Join Date
    Apr 2008
    Posts
    18
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    ok thanks

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    there are 3 ways to declare CSS styles

    1. External - when you create a separate file of CSS Styles and you include (link) it to the page. It is recommended that it be placed inside the <head></head> tags, however it will be recognized if placed elsewhere in the file.
    Code:
    <head>
          <link type="text/css" rel="stylesheet" href="/path/to/file.css" media="all">
    </head>
    2. Embed - when you create a stylesheet inside the page that will display it. It is recommended that it be placed inside the <head></head> tags, however it will be interpreted if declared anywhere in the page.
    Code:
    <head>
    
    <style type="text/css" media="all">
    body {
         margin: 0;
         padding: 0;
         background: #hexadecimal url('/path/to/image.gif') repeat top left;
         color: #hexadecimal;
    }
    </style>
    
    </head>
    3. Inline - CSS Styles that are declared within the tag that they will affect. These styles will not affect any other styles but the one they are declared within (persay - if you change a CSS property that effects the width and height of the element than surrounding tags will be affected, indirectly)
    Code:
    <div style="background-color: #000000; color: #ffffff">BLACK BACKGROUND, WHITE TEXT</div>
    White space inside the style declaration should not make a difference, in theory (can never count on IE handling something properly) The way I have declared these styles are typical syntactical layout, however there are no standards on exactly how something must be written (in terms of whitespace / alignment). Clients / Employers however, may suggest or enforce a coding technique or style guide when composing computer code

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    If you have large inline style blocks, you can use linebreaks there too:
    Code:
    <a href="foo.html"
       style="background-color: black;
              color: white;
              text-decoration: none;"
       class="bar">
      Anchor text
    </a>
    However, in this case it's likely that you should be using a class anyway.

    Note: there are many ways of aligning multi-line HTML tags, here I've used a variant on the Lisp pretty-printing style.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •