Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > CSS
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

CSS CSS styling code help for your website, CSS is like art and what makes your website look professional.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 09-05-2007, 12:41 AM   #1
neta
Service Man
 
neta's Avatar
 
Join Date: Aug 2007
Location: sweden
Posts: 291
My Photos: (2)
iTrader: (0)

Banked:
MK Cash: $8.81

I am Worth:
MK Cash: $1.18
Donate


neta will become famous soon enoughneta will become famous soon enough
Thumbs up CSS Syntax

Syntax

The CSS syntax is made up of three parts: a selector, a property and a value:

selector {property: value}

The selector is normally the HTML element/tag you wish to define, the property is the attribute you wish to change, and each property can take a value. The property and value are separated by a colon, and surrounded by curly braces:

body {color: black}

Note: If the value is multiple words, put quotes around the value:

p {font-family: "sans serif"}

Note: If you wish to specify more than one property, you must separate each property with a semicolon. The example below shows how to define a center aligned paragraph, with a red text color:

p {text-align:center;color:red}

To make the style definitions more readable, you can describe one property on each line, like this:

p
{
text-align: center;
color: black;
font-family: arial
}


Grouping

You can group selectors. Separate each selector with a comma. In the example below we have grouped all the header elements. All header elements will be displayed in green text color:

h1,h2,h3,h4,h5,h6
{
color: green
}


The class Selector

With the class selector you can define different styles for the same type of HTML element.

Say that you would like to have two types of paragraphs in your document: one right-aligned paragraph, and one center-aligned paragraph. Here is how you can do it with styles:

p.right {text-align: right}
p.center {text-align: center}

You have to use the class attribute in your HTML document:

<p class="right">
This paragraph will be right-aligned.
</p>

<p class="center">
This paragraph will be center-aligned.
</p>

Note: To apply more than one class per given element, the syntax is:

<p class="center bold">
This is a paragraph.
</p>

The paragraph above will be styled by the class "center" AND the class "bold".

You can also omit the tag name in the selector to define a style that will be used by all HTML elements that have a certain class. In the example below, all HTML elements with class="center" will be center-aligned:

.center {text-align: center}

In the code below both the h1 element and the p element have class="center". This means that both elements will follow the rules in the ".center" selector:

<h1 class="center">
This heading will be center-aligned
</h1>

<p class="center">
This paragraph will also be center-aligned.
</p>


Remark Do NOT start a class name with a number! It will not work in Mozilla/Firefox.

Add Styles to Elements with Particular Attributes

You can also apply styles to HTML elements with particular attributes.

The style rule below will match all input elements that has a type attribute with a value of "text":

input[type="text"] {background-color: blue}


The id Selector

You can also define styles for HTML elements with the id selector. The id selector is defined as a #.

The style rule below will match the element that has an id attribute with a value of "green":

#green {color: green}

The style rule below will match the p element that has an id with a value of "para1":

p#para1
{
text-align: center;
color: red
}


Remark Do NOT start an ID name with a number! It will not work in Mozilla/Firefox.

CSS Comments

Comments are used to explain your code, and may help you when you edit the source code at a later date. A comment will be ignored by browsers. A CSS comment begins with "/*", and ends with "*/", like this:

/* This is a comment */
p
{
text-align: center;
/* This is another comment */
color: black;
font-family: arial
}
neta is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 09-11-2007, 4:22 AM   #2
countryboy
MK PitStop Member
 
countryboy's Avatar
 
Join Date: Aug 2007
Posts: 133
My Photos: (0)
iTrader: (0)

Banked:
MK Cash: $0.00

I am Worth:
MK Cash: $5.87
Donate

Recent Blog: None

countryboy is on a distinguished road
Default

thnx for the information
countryboy is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 09-13-2007, 7:52 AM   #3
neta
Service Man
 
neta's Avatar
 
Join Date: Aug 2007
Location: sweden
Posts: 291
My Photos: (2)
iTrader: (0)

Banked:
MK Cash: $8.81

I am Worth:
MK Cash: $1.18
Donate


neta will become famous soon enoughneta will become famous soon enough
Default

you can try it or use it. so your web site or HTML file as like dynamic web site.
neta is offline  
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Syntax Error jared.pohl@gmail.com Database 0 07-01-2007 8:32 PM
Help on Syntax error please Gilles Database 0 07-01-2007 8:30 PM
Syntax problem John Olav Database 2 07-01-2007 6:35 PM
Syntax error? Joneleth Database 2 07-01-2007 6:01 PM
IF THEN ELSE syntax mzi Database 0 05-31-2007 7:47 PM


Featured Websites




All times are GMT +1. The time now is 9:32 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98