Help:CSS: Difference between revisions
m (hate those delays...by Sunday.) |
(→List of Properties and Values: added quite a bit.) |
||
Line 1: | Line 1: | ||
{{construction|by Sunday}} | {{construction|by Sunday}} | ||
#''Be familiar with [[Help:Color codes|hex colors]] before reading this.'' | #''Be familiar with [[Help:Color codes|hex colors]] before reading this.'' | ||
#'' | #''Many of the codes shown on this page can be used as {{link|Help|table}} styles.'' | ||
---- | ---- | ||
Line 12: | Line 12: | ||
<pre>body { | <pre>body { | ||
color: #00FF00; | color: #00FF00; | ||
} | |||
</pre> | </pre> | ||
The selector/element that was edited was ''body'' – all the general text on a page. The property/attribute was ''color'' – text color. The value was ''#00FF00'' – making all text a green color. | The selector/element that was edited was ''body'' – all the general text on a page. The property/attribute was ''color'' – text color. The value was ''#00FF00'' – making all text a green color. | ||
Note the syntax for CSS. The selector is defined first, then an opening brace (<tt>{</tt>) "opens" the element for editing. Then the property appears, with a colon (<tt>:</tt>) after it, then the value (hex colors must have the # sign). Each time a value is set, a semicolon (<tt>;</tt>) is required at the end (except for the last line). Multiple lines of properties and redefined variables can occur within the element, as long as they are closed by a closing brace (<tt>}</tt>). | Note the syntax for CSS. The selector is defined first, then an opening brace (<tt>{</tt>) "opens" the element for editing. Then the property appears, with a colon (<tt>:</tt>) after it, then the value (hex colors must have the # sign). Each time a value is set, a semicolon (<tt>;</tt>) is required at the end (except for the last line). Multiple lines of properties and redefined variables can occur within the element, as long as they are closed by a closing brace (<tt>}</tt>). | ||
<pre>selector { | |||
property1: value; | |||
property2: value; | |||
property3: value; | |||
} | |||
</pre> | |||
Keep in mind that while the wiki has selectors that are common to all sites, some of them are also unique to wikis only | Keep in mind that while the wiki has selectors that are common to all sites, some of them are also unique to wikis only | ||
The following is a list elements, attributes, and values that are common to be changed, thus likely vital to your CSS page. | The following is a list elements, attributes, and values that are common to be changed, thus likely vital to your CSS page. | ||
== | ==Example== | ||
{{user|Wayoshi}} ''has been kind enough to allow us to use [[User:Wayoshi/monobook.css|his CSS page]] for | {{user|Wayoshi}} ''has been kind enough to allow us to use [[User:Wayoshi/monobook.css|his CSS page]] for an example first, using all three parts of CSS.'' | ||
Let's take a look at the "body" and "a" selectors | Let's take a look at the "body" and "a" selectors: | ||
<pre>body { font-family:Arial; font-size:10px;} | <pre>body { font-family:Arial; font-size:10px;} | ||
a { color: #080; text-decoration: none; } | a { color: #080; text-decoration: none; } | ||
Line 43: | Line 48: | ||
*'''#bodyContent a.extiw:active''' is when an external link is being clicked on. | *'''#bodyContent a.extiw:active''' is when an external link is being clicked on. | ||
*Result: Normal text is changed from 12px Verdana to 10px Arial. The normal and external links are now green. When clicking on a link, the color is a dark shade of green or gray. The uncreated page links are a darker shade of red. | *Result: Normal text is changed from 12px Verdana to 10px Arial. The normal and external links are now green. When clicking on a link, the color is a dark shade of green or gray. The uncreated page links are a darker shade of red. | ||
*In the | *In the first example, different parts were on different lines. In fact, all of it can be on one line if you so choose. Incidentally, there is no need for a space inbetween the colon and the value as well. | ||
==List of Properties and Values== | |||
Single bullets show properties, indented bullets show values. Some properties are grouped if they take the same type of values. | |||
*font-family – also known as the "font face". | |||
**Many font types. Check out ''Microsoft Word'''s list – over 90% of those fonts are compatible. | |||
*font-size | |||
**<tt>___%</tt> increases the font as a ratio to the default font size. There is also <tt>px</tt> and <tt>pt</tt> – px is actual pixels and pt is as it would appear in ''MSWord''. | |||
*color, border-color | |||
**Accepts either color names (check out [http://www.w3schools.com/css/css_colornames.asp this expansive color list]) or hex colors. | |||
*border-style | |||
**dotted, dashed, solid, double, groove, ridge, inset and outset | |||
*border-width | |||
**Must use pixels, suggested that they are only positive integers – decimals such as <tt>1.5</tt> causes two sides to be 1px and two sides to be 2px | |||
*border, border-top, border-bottom, border-left, border-right | |||
**Unique shorthand way to define ''width'', ''style'', and ''color'' in one declaration: <tt>border: 1px dashed black;</tt>, <tt>border: 2px solid #289;</tt>. Only one side can be affected by using the last four properties if one so chooses. | |||
*background, background-color | |||
**Can be a color value OR a ''complete'' url – <tt>background:url(<nowiki>http://www.imagesite.com/youralbum/bgpic.jpg</nowiki>);</tt> | |||
*margin, margin-top, margin-bottom, margin-left, margin-right – Margin sets space between elements themselves. Honestly, it won't be used that much on a wiki. | |||
**Margin has a lot of measurements (px, em, cm, etc) but all do the same (ie a paragraph with a margin-bottom of 100px would look separated from the other paragraphs). | |||
*padding, padding-top, padding-bottom, padding-left, padding-right – Padding sets space in between the border of an element and its text. | |||
**Pixels only. Here decimals are OK. | |||
*list-style-image | |||
**This is special for the <tt>ul</tt> (unordered [bullet] list) selector, and can change the 5X5 pixel bullet image. More on this below. | |||
*-moz-border-radius, -moz-border-radius-topleft, -moz-border-radius-bottomleft, -moz-border-radius-topright, -moz-border-radius-bottomright – this Firefox-only property cuts off corner[s] at the edge of a table by a specified amount – that is, making the edge rounded. | |||
**Takes pixels or ''em''s. One em is – wide (yes, the ''em dash'' is the long dash standardly used on this wiki). |
Revision as of 20:03, November 25, 2006
This article is under construction. Therefore, please excuse its informal appearance while it is being worked on. We hope to have it completed by Sunday.
- Be familiar with hex colors before reading this.
- Many of the codes shown on this page can be used as Template:Link styles.
CSS (officially known as Cascading Style Sheets) sets how a page looks. On a special sub-page on your user page, you can override the Monobook skin to create your own personal look for the wiki.
Background
CSS has three parts: A selector is the variable (officially the HTML element you're editing). A property is the attribute of the element you want to change. Each property has a value, which is set by default and the true item you are changing.
Consider the following line:
body { color: #00FF00; }
The selector/element that was edited was body – all the general text on a page. The property/attribute was color – text color. The value was #00FF00 – making all text a green color.
Note the syntax for CSS. The selector is defined first, then an opening brace ({) "opens" the element for editing. Then the property appears, with a colon (:) after it, then the value (hex colors must have the # sign). Each time a value is set, a semicolon (;) is required at the end (except for the last line). Multiple lines of properties and redefined variables can occur within the element, as long as they are closed by a closing brace (}).
selector { property1: value; property2: value; property3: value; }
Keep in mind that while the wiki has selectors that are common to all sites, some of them are also unique to wikis only
The following is a list elements, attributes, and values that are common to be changed, thus likely vital to your CSS page.
Example
Wayoshi (talk) has been kind enough to allow us to use his CSS page for an example first, using all three parts of CSS.
Let's take a look at the "body" and "a" selectors:
body { font-family:Arial; font-size:10px;} a { color: #080; text-decoration: none; } a:visited { color: #050; } a:active { color: #111; } #p-personal a.new { color: #b00; } #p-personal a.new:visited { color:#800; } #bodyContent a.external { color: #0a0; } #bodyContent a.extiw:active { color: #020; }
- The body selector covers the basic text on any page (such as what you'd see as content on a wiki page).
- The a selector is the basic link that hasn't been clicked on recently.
- a:active is when you are in the midst of clicking the link.
- a:visited is the link that has been clicked recently. Often, it is simply the same color, but darker than a.
- #p-personal a.new is the wiki-unique link-that-hasn't-been-created (red) link.
- #p-personal a.new:visited is when you try to create a page, but don't right away, so it has a different color elsewhere until it's created, when it becomes a.
- #bodyContent a.external is the external link.
- #bodyContent a.extiw:active is when an external link is being clicked on.
- Result: Normal text is changed from 12px Verdana to 10px Arial. The normal and external links are now green. When clicking on a link, the color is a dark shade of green or gray. The uncreated page links are a darker shade of red.
- In the first example, different parts were on different lines. In fact, all of it can be on one line if you so choose. Incidentally, there is no need for a space inbetween the colon and the value as well.
List of Properties and Values
Single bullets show properties, indented bullets show values. Some properties are grouped if they take the same type of values.
- font-family – also known as the "font face".
- Many font types. Check out Microsoft Word's list – over 90% of those fonts are compatible.
- font-size
- ___% increases the font as a ratio to the default font size. There is also px and pt – px is actual pixels and pt is as it would appear in MSWord.
- color, border-color
- Accepts either color names (check out this expansive color list) or hex colors.
- border-style
- dotted, dashed, solid, double, groove, ridge, inset and outset
- border-width
- Must use pixels, suggested that they are only positive integers – decimals such as 1.5 causes two sides to be 1px and two sides to be 2px
- border, border-top, border-bottom, border-left, border-right
- Unique shorthand way to define width, style, and color in one declaration: border: 1px dashed black;, border: 2px solid #289;. Only one side can be affected by using the last four properties if one so chooses.
- background, background-color
- Can be a color value OR a complete url – background:url(http://www.imagesite.com/youralbum/bgpic.jpg);
- margin, margin-top, margin-bottom, margin-left, margin-right – Margin sets space between elements themselves. Honestly, it won't be used that much on a wiki.
- Margin has a lot of measurements (px, em, cm, etc) but all do the same (ie a paragraph with a margin-bottom of 100px would look separated from the other paragraphs).
- padding, padding-top, padding-bottom, padding-left, padding-right – Padding sets space in between the border of an element and its text.
- Pixels only. Here decimals are OK.
- list-style-image
- This is special for the ul (unordered [bullet] list) selector, and can change the 5X5 pixel bullet image. More on this below.
- -moz-border-radius, -moz-border-radius-topleft, -moz-border-radius-bottomleft, -moz-border-radius-topright, -moz-border-radius-bottomright – this Firefox-only property cuts off corner[s] at the edge of a table by a specified amount – that is, making the edge rounded.
- Takes pixels or ems. One em is – wide (yes, the em dash is the long dash standardly used on this wiki).