View Full Version : the way css is organized
apoc.3.21
04-01-2008, 06:24 PM
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?
NXArmada
04-01-2008, 06:26 PM
Most common way of writing CSS
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;
}
apoc.3.21
04-01-2008, 06:27 PM
that's in the head, but what about in the body?
NXArmada
04-01-2008, 06:29 PM
Then left to right
style="margin-bottom:3px; border-bottom-width:0px; width:100%; text-align:left"
apoc.3.21
04-01-2008, 06:35 PM
ok thanks
boogyman
04-01-2008, 09:10 PM
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.
<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.
<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)
<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
If you have large inline style blocks, you can use linebreaks there too:
<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.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.