|
|
hi there.Hi and welcome to my second ever guide. xD This is a tutorial into the beginnings of CSS and HTML website coding, as I'm sure you figured by the site's name. Since I only learned it on Neo myself, I hope I can make it as un-confusing and easily understood as possible. :) This is mainly a CSS guide, because for me CSS does most of the work on my pages. You know those big projector light things? Think of CSS as the filters, telling the light to be what colour and where to have dark bits and stuff. HTML is the light source- without the correct HTML bits, CSS won't do anything, but without CSS, HTML looks very plain and boring, unless you're going to manually tinker the light source, which is obviously much harder.This guide is unlike most other coding guides in that instead of giving the user already-written code and explaining it, it teaches the user to construct the code themselves, bit by bit. By the end of it, if you succeeded, you'll be able to write a completely coded page on your own, with no need for copying and pasting. Anyway, I suppose I should get started. All coding bits are shown in the pink and orange boxes. If you think there's anything that should be added, please NM me, tintytiny909. Enjoy! Note: As this guide aims more to give a full understanding of basic coding rather than to teach you how to make a specific type of page, it doesn't include all the extra bits that any page other than a petpage has. Of course, userlookups, petlookups, shops, galleries, guilds and so on use exactly the same type of coding, so you can use the knowledge learned here there as well- the only difference is that all the other layout types have preset things by Neo you have to code as well (lookups have the stat tables, for example, guilds have the sidebar, shops have the items and things), which adds too much complication- I can't explain every single type of layout thoroughly in just one page. Still, learning to code petpages fluently will benefit you hugely when you turn to other pages- if you have a good knowledge of petpage coding, figuring out how to do the rest from looking at premades and other layouts should be no problem.
the basics of CSSFirst off, if you've never seen coding before, I suggest you get a grasp of the most basic things in HTML- try here. :) You need to have an understanding of the most fundamental things in coding and what it looks like, to be able to understand the rest of this guide.Okay, let's be honest here. To begin with, CSS probably looks like a whole load of odd words separated by a whole load of odd bits, all of which is completely beyond your understanding. But actually, it's not that hard. The reason some nice person has put understandable words in is so you won't have to memorize a bunch of code in, say, binary or whatever. xD So, if you work with it long enough, sooner or later you'll understand it just like normal English. Every bit of CSS you put in has to be enclosed by special CSS tags, to separate it from the HTML. The tags look like this:
All your CSS bits and pieces go in between the two tags. The actual CSS that goes inside the tags looks like this:
thing {
bit:changes; } This is a single CSS group. As you can see, you tell the page what you want to make changes to by putting it in front, then you enclose the actual changes in fancy twirly brackets, { and }. The 'thing' part is the selector, or the part of the page which you want to change. So say we want to change the body of the page (which is the entire page in general), we'd put:
body {
bit:changes; } The 'bit' part is the attribute, or the thing about the selector that you want to change. So now let's say we wanted to change the background of the body:
body {
background:changes; }
And the 'changes' part refers to the property, which is what you want to change it to. So if we're changing the background of the body to pink, we'd put:
body {
background:pink; } If we wanted to add more attributes and properties to the same selector, we'd do it like this:
body {
background:pink; cursor:crosshair; } The cursor attribute changes the cursor that's used while viewing your webpage. A semi-colon has to be used after you've finished typing each attribute to separate it from the next one. ;) Simple enough, eh? Got all that? :) Let's move on then.
all the selectors you might ever needI'm going to try and do this my way. Most guides teach you how to build a webpage by giving you the code template but I like for you to be able to put it all together yourself- then you won't have to keep coming back to copy and paste, once you've remembered all this. (Yeah, it's a fair amount, but don't worry. If I can do it, why shouldn't you?) So this section tells you what all (or most, anyway) of the fixed selectors are and what they refer to. (You can also add your own, for divs and classes, but we'll do that later.)
body {
The fundamental layer of the page, not including any bits you assign more CSS to. We usually only use this for background and cursors, so don't worry too much about it.
p {
Text you put the paragraph tag on. I don't use this often, but you might find some use for it.
table {
Things you put in a table. You might think you're never going to use this because you're not very likely to use a table, but actually this might crop up a lot- the irritating banner on the top of the page is in a table, for example, and you can also use tables as textboxes. (In fact, this layout is a table.)
h1 {
Text you put the header, or h1, tag on. If you need more than one style of header, you can create more selectors, with h2 and h3 and so on- you just have to remember to use the right corresponding header tag when you need to use them.
b {
Text you put in bolded tags.
i {
Text you put in italic tags.
u {
Text you put in underline tags.
a {
All links that you use in your text. If you want to have a better control over how you customize your links, see the selectors below.
a:link {
Links when you haven't clicked them or hovered over them or anything.
a:hover {
Links when you hover over them.
a:active {
Links when you're currently clicking them.
a:visited {
Links after you've already clicked on them- as in, already visited the link.
textarea {
All textareas you use.
img {
All the images you have in your layout.
ul {
Text you put in the bullet-list tags.
ol {
Text you put in the number-list tags.
.sf {
The copyright thing at the end of the page (you know, the one that says, 'NEOPETS, characters, logos etc. are trademarks of Neopets Inc. blah blah').
Note: There's different tags for all the other stuff on a regular Neo page as well, like the clock and the navigation bar and so on, but since this is the only one which shows up on a petpage, apart from the homepage banner (which doesn't have a specific selector), it's all you're going to need. If you want to assign the same configuration to more than one selector, you put both before the same fancy bracket, separated by a comma and a space. So say you wanted both the normal links and the visited links to be blue, you'd put this:
a:link, a:visited {
color: blue; } You can also specifically configure a certain selector of another selector (or div- I'll get to divs later) rather than just one whole selector and everything under it. This is helpful to narrow down what gets changed. For example, instead of telling all headers (h1) to be red, you could tell only the headers inside tables (table) to be red, like this:
table h1 {
color: red; } Confused yet? Don't worry, hopefully it'll start to make sense soon. :) creating divsSo, now you've gone through all the preset selectors that you'll probably ever need in a petpage. However, you can also write your own selectors, which create and control a particular element of the page, whether textbox, image or anything else, that you'd like to assign a name and specific attributes to. This is essential for telling your text where to go, putting in navigation and a whole load of other stuff, so let's learn how, eh? ;)These selectors you create yourself are called divs. There are two types of div- ID divs, and class divs. The CSS selector for ID divs look like this: #box {
And class divs look like this: .box {
You can call them any div name you want in the place of 'box'; the div name is to tell the page which div you're referring to, when you code it later on in HTML. As I'm sure you've noticed, ID selectors are preceded by a # and class selectors are preceded by a . The difference? ID divs only configure one specific thing- for example, you might want just one box to be red with red borders, then you create an ID because you don't need the same coding for anywhere else on the page. However, class divs can configure multiple things the same way- like, say you want three boxes, and they all have to be blue with blue borders, then you can create a class that specifies a blue colour with blue borders, and assign the same class to all boxes. One element of the page can have both an ID and a class- so say you want two textboxes, in different places but both blue with blue borders, you'd write different IDs for each of them to tell them their different places on the page, but also a combined class for both for the blue colour and blue borders.
attributes & propertiesSo now you know all the preset selectors as well as how to create your own divs- but you can't do anything without knowing the coding you use to configure them, right? Here's a list of all the basic attributes, and all the properties that go with them.
size & positionwidth:100px;
Changes the width, or horizontal length, of the selector. You can put a specific number in pixels, OR a percentage of a user's screen. The first option will appear the same size with everyone, but the second option will vary depending on how big the user's screen is.
width:100%; height:100px;
Changes the height, or vertical length, of the selector, in the same way as the width.
height:100%; left:100px;
The distance from the leftmost point of the screen to the selector, or from the inside of the element, in pixels. We'll learn how to specify which one a little later on.
top:100px;
The distance from the topmost of the screen, etc. etc.
bottom:100px;
The distance from the bottom of the screen.
right:100px;
The distance from the right of the screen.
text decoration, transform & aligntext-decoration:none;
text-decoration:underline; text-decoration:overline; text-decoration:line-through; Text-decoration configures whether you have lines on your text or not, and where the lines go- underneath, over, or through the text. text-transform:lowercase;
This attribute forces the text in question to be lowercase, uppercase or with capital letters at the beginning of each word (regardless how it's actually typed).
text-transform:uppercase; text-transform:capitalize; text-align:left;
This tells your text to align to the left, center, right or to justify- just like on your word processor.
text-align:center; text-align:right; text-align:justify; fontfont-style:normal;
Font-style tells your computer whether the text is to be displayed in italic or normal.
font-style:italic; font-weight:normal;
Tells your computer whether the text is to be displayed in bold or normal.
font-weight:bold; font-size:10px;
Font-size, as you can tell, configures what size the font is to be. It can be written in px OR pt- px is specifically how big in pixels the font is, whereas pt is more like the sizes on a word processor.
font-size:10pt; font-family:"verdana";
Tells your computer what font to use for the text. :)
color:#ff0000;
The colour of the text. (Yes, it has to be written the American way.) Like the size, it can be written two ways- you can write the base colour, which shows up as a default colour for that particular hue, or you can choose a hexcolour using an imaging program or from a list, which gives a specific indication of what shade it is to be.
color:red; font-variant:none;
Small-caps makes all the text capitals, but there are big capitals for everywhere you put a capitalization and small capitals for what would've been lowercase text. ;D Pretty cool.
font-variant:small-caps; borderborder-style:solid;
As you can see, there's all these lovely border styles you can try out, although just solid, dashed and dotted will probably do you fine.
border-style:dashed; border-style:dotted; border-style:groove; border-style:outset; border-style:inset; border-style:ridged; border-width:2px;
Changes how thick your border is.
border-color:#ff0000;
The colour of the border. Likewise, it can be written either as a base colour or as a specific hexcolour.
border-color:red; backgroundbackground-color:#ff0000;
Colour of the background.
background-color:red; background-image: url("http://neopets.com");
If you want to have an image rather than a solid colour as a background, this is the code you use. You need to get the URL of the image- if it's on your computer, it has to be uploaded to an image hosting service. :)
background-attachment:fixed;
This tells your background whether to be fixed or to scroll. (The default is normally scroll.) A fixed background doesn't move even while the rest of your page scrolls, but a scroll background scrolls with your text and other stuff.
background-attachment:scroll; background-repeat:no-repeat;
The background defaults to the 'repeat' setting- as in, repeat infinitely in every direction. However, you can tell it to not repeat at all, or only repeat along the x axis (horizontally) or along the y axis (vertically).
background-repeat:repeat-x; background-repeat:repeat-y; background-position:left;
This tells your background where to position itself. You can tell it to go to any combination of two positions from left, right, center and top and bottom (like 'top left' or 'center bottom'), or you can just tell it to position with a single base direction.
positionposition:absolute;
Note: these two codes cannot be put inside the style tags, because of TNT's filters. They have to be added in a style section inside the HTML tags- we'll learn how to do that in a bit.
position:relative; Absolute tells the position you've given the selector to be taken from the edges of the browser window; relative tells the position to be taken from inside the element. You'll probably use absolute more than relative. ;) spacingpadding:5px;
Padding makes an extra bit of room within the element- this text, for example, has padding of 5px, and you'll notice there's a little gap of 5px between the text and the border of the box. It's handy to stop the text being squashed up directly against the edges. ;)
margin:5px;
Margin makes an extra bit of room outside of the element, which means there'll be a gap around the element instead of inside.
line-height:12px;
Line-height controls how much space there is between the lines of your text. You can even make the text overlap vertically, if you like, by putting in smaller values. ;)
letter-spacing:4px;
Letter-spacing is how much space there is between the individual letters of the text. If you put in negative values you can make the text overlap horizontally. This, and the above, are handy if you're running out of space and want to squeeze a bit more in, or vice versa. xD
displaying & visibilityvisibility:visible;
You can make elements invisible or force them to show by using this attribute. :)
visibility:hidden; display:block;
The display attribute controls how your stuff is displayed. Block makes it take a new line break for every new bit, inline keeps it all on the same line, and none... well, you can guess. :P
display:inline; display:none; Note: What's the difference between visibility:hidden and display:none? Visibility merely controls whether the element is visible or invisible; an 'invisible' element will still take up the space allocated to it. Whereas, if you use display, an element set to 'display:none' will actually cease to exist. listslist-style-type:none;
This controls the shape of the bullet points in the bulletted lists on your page. Have fun. :)
list-style-type:disc; list-style-type:circle; list-style-type:square; cursors
cursor:crosshair;
cursor:pointer; cursor:text; cursor:not-allowed; cursor:n-resize; cursor:e-resize; cursor:ne-resize; cursor:nw-resize; There's actually a whole load more, but this will probably be more than enough. This changes the shape of the cursor while hovering over the part of your webpage the code is assigned to. miscellaneousz-index:3;
This one controls the layering- in other words, what shows up on top of what. Something with z-index 1 will show up on top of something with z-index 0; something with z-index 2 will show up on top of something with z-index 1 and so on.
float:left;
Float is a bit like text-align, but you can't use align for images, divs and the like, so float does basically the same thing.
overflow:auto;
Overflow is when the text or whatever you put inside the element doesn't fit inside, creating a scrollbar. Writing overflow:hidden hides the scrollbar, and makes the layout nicer to look at. You can do this with general overflow, but you can also only hide the overflow vertically with overflow-y, or horizontally with overflow-x.
overflow:hidden;
overflow-y:auto;
overflow-x:auto; attribute:property!important;
This isn't really an attribute or property, but it's something you'll be using. The !important bit tells your computer have this property override everything else you've written. Useful for when you need to make some exceptions to your code, or make your code override Neopets's defaults.
shortcutsNow, using the tags above is all very well, and they'll serve you fine. However, everyone loves shortcuts, right? ;) Yes, it does mean some more things to remember, but it's only a little and it'll save you some typing and character space when you're coding.Certain groups of CSS attributes can be all put into one line of CSS instead of several. For example, instead of putting this:
#text {
font-weight:bold; font-size:8pt; font-family:"verdana"; line-height:16px; letter-spacing:-2px; } We can just put this:
#text {
font: bold 8pt "verdana" 16px/-2px; } Much easier, eh? :) You can do this for fonts, backgrounds and borders. You can also use shorthand for margin and padding, but they have to be in a specific order or it won't work. Here's an example:
#text {
margin-top:1px; margin-right:2px; margin-bottom:3px; margin-left:4px; } To convert this to shorthand, we write:
#text {
margin: 1px 2px 3px 4px; } The numbers have to be in this order- top, then right, then bottom, then left. The same applies for padding shorthand. ^_^ adding HTMLNow we're moving on to HTML. To me, HTML's merely a tool, just to display the show and glitter of CSS. But it's still very important you get your HTML right, so let's see how.
divsEach CSS div and table you create must have an HTML counterpart- you have to put the HTML in place otherwise there's nothing for the CSS to configure. The HTML counterpart for a div will look like this:
The basic HTML for a div, as you probably know, is just a 'div' beginning tag and then another '/div' end tag, with your content in between. However, when you use CSS to configure a div, you have to tell the page which div you want that specific CSS to appear on, so you insert the ID name or class name (or both, if it has both a class and an ID) that you gave the div in your CSS. You'll also see there's this part called style, and you'll probably recognize it as CSS. What's it doing among the HTML then? Well, for this particular piece of style, the position attribute, it's disallowed in the style tags, so we have to put it in the HTML instead. However, there's another use for style-in-HTML- you can tell the style to apply to that element only, whereas any CSS you put within your style tags will apply to everything. This isn't terribly useful for divs, because you can create specific selectors for specific divs, but it's very useful if you're using a table as your main text container, like this layout. Since you can't give a table a specific name, you can add the style within the HTML, and it'll apply to that table only. :) You can change the style bit as you like, the 'position:absolute;' is only an example, although it is the most common style-in-HTML I usually use, and if you assigned an absolute position to the div you'll be needing it anyway. Once you've done that, all there is to it is to put whatever actual stuff you want to replace the 'your stuff goes here' bit, be it navigation links or text. So there we are! :)
tablesYou can also use tables like text containers. (We'll find out how later.) Table HTML is much like div HTML, only it says, well, table instead of div. (What did you expect?) Here's the standard coding for a table:
Note that you can't position absolute a table- it has to align to either the right, the left, or the center. You can replace the 'center' tag with whatever alignment you want it to have. Also, you can't give tables specific div names, so when you have multiple tables it's a little harder to handle, and you'll have to style-in-HTML code them individually. imagesAnother thing you'll be putting an HTML tag for is images. (Obviously, you replace my image link with your own.)
Of course, simple in-text images don't have an ID or position, you just use the 'img src' and '/img' codes, but for special images like headers, you can also assign a div to images, which you can use to position it, put a border around it etc. Like the text div, you'll just write the positioning of the image into your CSS and then use the ID where the 'name' is. page anchorsThere's also a few little gimmicks I'd like to teach you to use in your HTML, and the first of them is page anchors. These are like links that take you straight to a certain part of the page, rather than you having to find it yourself. You've probably seen it before- in fact, this page has anchors, so you don't have to find all the sections by scrolling if you need a certain part, you can just click the links at the top. There are two parts to a page anchor- one is the actual anchor, and the other is the link.Let's see how to make the anchor first. Let's say you want to link to some text that says AWESOMENESS, and you want your anchor to be called awesomelink. All you have to do is this:
You put the 'a name' tag just before the bit you want to link to, and give it a name. Now, wherever you want to put in the link to the AWESOMENESS section of the page, you type this:
It's just like an ordinary link, except that instead of a URL you have the name you gave the anchor with a # in front, which in this case is '#awesomelink'. Simple. :) separate-page anchorsThe above page anchor code is the simplest type, and you can make links to certain places in the page. However, you've probably seen a different type of page anchor, usually in a textbox- unlike the previous code, you can't see the other parts of the page until you click on the anchor, as if there were lots of separate pages inside one page. Pretty cool, eh? ;D And the good news is, you can do that too.The coding is the same as the simple page anchor, but with a few more bits in the div coding. If you're going to do this, you need to code two divs in your CSS. The first div is for the position and size of the actual textbox. The second one is the class you'll use each time you want to create another separate page in your textbox. :) It'll look something like this:
#box {
left:100px; top:100px; width:500px; height:600px; overflow:hidden; }
.text { You'll see I've put 'overflow:hidden' in the first div- that's so the actual box doesn't extend or scroll when you put stuff in it. You've got to retype the height in your class div, the same height you used for the box, and you also put your font and stuff in there. (Of course you can change the names of those divs how you want, but for example's sake I'll continue using those names.) Now, moving onto the HTML needed. You have to type in the div code for the ID first, and then the ending tag. Then you put the code for your class in, and end it every time you want another separate page. And so people can actually reach the pages underneath the first page, you have to put page anchors so you can click them and get to the pages underneath. Also, remember that each div ID and class you have has to have a matching end tag. Bit confusing? No worries, it'll clear up in a moment. So say you want two separate pages, one called butter and one called bread, you put this:
Easy, eh? :) Don't forget to put the link to the anchor as well, like this:
Of course, you're welcome to replace the random names I've given to the divs and anchors as you like. floating elementsEver noticed when someone's had a page with an element, usually an image or navigation, that doesn't move even while the rest of the page scrolls? This is called a 'fixed' or 'floating' element.The very simplest way to make a fixed element is to add 'position:fixed' inside its style-in-HTML. Yes, it's very simple, isn't it? But thanks to IE having so many weird problems (-_-), this doesn't work in IE. So we take a more roundabout route. The basic idea of making a floating element while everything else scrolls is to have two different layers on your page- one which scrolls, and one which doesn't. The floating element would be on the not-scrolling layer, while everything else would be on the scrolling one. Sound simple enough? We use the body layer as the not-scrolling layer. To do this, we simply put this in our CSS:
body {
overflow:hidden; } That will stop the body from scrolling. Then, on top, we create another layer. Since we can't have two bodies in the page, we create a substitute one by making a huge div that fills the entire screen and therefore is basically another body:
#body2 {
left:0px; top:0px; width:100%; height:100%; overflow:auto; } You see we've put 'overflow:auto' this time rather than 'overflow:hidden', which means the second 'body' will scroll. Now, outside of your style tags, make the HTML counterpart for the second body div we just made. That's where all your other content goes; since that div is set to overflow:auto, everything inside it will scroll normally. Then, outside of the second body div, put your floating element. Since this is outside of the scrolling div, and we've set the body to not scroll, this element will remain fixed. :) Whoopee! Here's the HTML in action, just so you don't miss it:
image mapsThere's one more little thing I'd like to teach you, and that's image mapping. Image mapping is basically making certain sections of an image become links. :)Image mapping is done by telling a certain section of an image to become a link. There are lots of different shapes you can use, but you can manage basically anything with the simplest shape, a rectangle, so I'll just teach you how to do a rectangle area. The image map code looks like this:
As you can see, an image map also has a name, just like divs and anchors do. The 'area shape' part tells it which shape to use. The ref part is like an ordinary link- you put your link URL there. The co-ordinates tell you where your rectangle will be. So how do you get these co-ordinates then? Well, the easiest way is to use an imaging program- if you don't have anything fancy, Paint is fine. Copy your image into the program, making sure that the canvas is exactly the same size as your image. Then, hover over where you want the top left corner of your rectangle to be, then look around the sidebars. You should see a little pixel count somewhere, telling you how far from the top and the left of the canvas your mouse is. This is exactly what you need. :) Note down the numbers, then repeat the same process with the bottom right corner of where you want your rectangle. Then you put them into the area bit, in place of the random numbers I put, in the order you noted them down, which should be the distance from the left for the top left corner, then the distance from the top for the top left corner, then the left to bottom right corner, then top to bottom right corner. Got that? :) Finally, you just need to add a bit of code to the image which you want the map to be used for, telling it to use a map. This is what it should look like:
putting it all togetherNow you know all the tidbits to know about CSS and HTML, you can throw it all into a page and pronto, you have a petpage! Right?Well, not quite. I expect you're still feeling a little lost, and probably not quite sure how to start, how to create your page. Well, I'm still here to help. Below are some step-by-step guides to create actual petpages, and hopefully that'll help you get started! Note: Obviously, these methods aren't the only ways you can make petpages. There are myriads of different methods people use. In fact, these three ways are merely examples, to show you how you can use the coding; I strongly encourage you to experiment and come up with your own style after you get the hang of it. style 1: continuous text with imageContinuous text is my name for text that continues forever down the page, and the only scrollbar is the one at the right side of the page- like this layout.Note: Of course, it's perfectly possible to code a continuous text layout without images too, and same with the textbox style a little later on; however, I suggest you practice with images first, it will give you more confidence. :) If you can't make images, you can use mine for practice, as long as they are actually only used for practice and never saved. If you want to show some other people what you've done to ask for help, you have to leave credit somewhere, and you cannot use them for an actual webpage.
Images needed:
2. Background image, repeatable vertically, like directly below. The text space needs to line up perfectly with that in your header image and the background has to match that on the header image to make it look like you just had one long textbox, so I usually get the background image from the header image by copying the part with the textbox, then extend it to 1500-2000px wide and fill in the remaining space on the right with the background pattern also. Why so wide? Well, it is possible to have two repeating backgrounds, but that's a lot more complicated, so to avoid having two I just make one background image fill all the space horizontally as well as vertically. So I make it a bit wider than what I think the widest screen would be, in order to make sure nobody sees plain background behind it, even if they have a monster screen. xD However, if you just want a plain colour as background, you don't have to make it so wide- as wide as your header image is enough.
Drag them into your browser to view full-size and get an idea of what they need to look like. :) How to code it: 1. Write in the style tags. Duh. 2. I usually start off my coding the body. Don't worry if this feels a bit alien, you'll get used to the coding soon. :) Just for a helper, here's the actual coding I usually put:
body {
background: url("YOUR IMAGE URL") repeat-y #COLOUR; } Replace the 'YOUR IMAGE URL' with the URL of the repeatable background image you uploaded. (You have to save your images onto your computer, find an image hosting site and upload them, then copy and paste the direct link.) Then, replace the COLOUR part with your own background hexcolour, in case somebody does have a monster screen- seeing plain colour is better than seeing plain white, right? xD If you're just using a plain colour as a background, remove the URL and the repeat bit and just have your hexcolour. You should be recognizing this CSS from the previous sections. The URL bit is the background image, repeat-y tells it to repeat vertically, and the colour is the background colour, all written in shorthand, right? Starting to click together now? :) 3. Now I put in the removal code. I found that with this way of coding the page, the credits the Neo filters automatically put in- the homepage banner and the copyright stuff- end up in awkward places and mess up the layout, so I usually just to remove them. (You can't see it when you press preview changes, but it'll show up when you save changes if you didn't remove them.) See if you can code it right by yourself now. ;) Remember, I told you how .sf is the class name of the copyright bits? And the homepage banner is in a table, and the display:none code stops things from showing up. So with those clues, try writing in the code. :) Shouldn't be too hard. And just to help you get the hang of it, check your answers here:
.sf, table {
display:none; } Did you get it right? If you did, well done, and move on to the next part. :) (I feel like a schoolteacher now.) 4. Here's the exciting part, and you get to do it on your own! ;D (Because I actually can't do it for you, unless I use my occult powers read your mind. Muahahaha!) At this point, I put in coding for the divs I'll need. (I usually have three to four- one for main text, one for navigation, one for my header image, and sometimes one for a sidebar.) Refer to the sections above if you need to, and have fun customizing the divs. ;) Put in the positioning and size first. My header image is usually left:0px top:0px, because the background has to be left:0px and top:0px (you can't position the background) and it has to line up. Then, I put in an absolute position and size for my other divs- textboxes, navigation etc. (Most imaging programs, even Paint, have a pixel count somewhere that tells you how far from the left and top your mouse pointer is, so all you need to do is paste in your header image, hover over where you want the div to start and note the pixel number.) Your text div needs an absolute position and a width, but not a height, because it's just going to continue as long as your page is. After that, don't forget the fonts and things. Since this might be your first page, it might be tempting to skip the scarier bits like navigation, but I encourage you to code a nav as well as a textbox, it'll give you experience with the fonts and colours and borders. :) 5. Now I write in code for any other selectors I want to configure- h1, a, textarea, b, i, u, and anything else I might want to change. 6. You're done with CSS! ;) Move outside the style tags, and start on the HTML. Remember, every div in your CSS has to have a corresponding div in HTML- so an image with the ID you gave your image code, a textbox with the textbox div name etc. I usually stick some sample text in the div to check all my CSS worked. Press 'preview changes' when you want to see what it looks like, and whether you did it right- adjust z-indexes, overflows etc. etc. accordingly. Once it's all in the right place and everything looks like it should, move on to the next step. 7. Now put in your actual text, navigation links and so on inside your divs. Keep pressing preview changes to check it looks all good. 8. Once you're happy with how it looks, press the 'save changes' button. (In this layout style, it should be somewhere on your header image.) Then, go to the actual URL of your petpage, and see if everything still works. ;) (Sometimes a problem doesn't show up in Preview Changes but it does on the actual page.) If it does, yippee, you just coded a perfect petpage!
style 2: continuous text with tableThere's one more way I can do continuous text, and that's with a table, like this layout- a one-celled table is the main text container. This is more simple in both coding and appearance; another benefit of this type of layout is that you can center it perfectly for everyone- so even if they have a monster screen, it'll still be in the center, which you can't do with the above div style. However, because the homepage banner is also a table, it causes a few complications with the removal tags; you also can't do sidebars, because everything, including navigation, has to be centered or it'll look out of place- remember, everybody's center position is different depending on the size of their screen.Images needed: 1. Header image. This is optional, but your table will look much nicer with one- it doesn't need a border, a textbox, or anything, the only thing it has to be is the same size as what you want your table to be. For example, say you want a table 600px wide, your image has to be 600px wide as well.
2. Background image. This is also optional. However, again it looks nice with a background image. :) The background image has to be a tileable image to go in your background (if you look at this layout, it would replace the plain dark grey I've got).
How to code it: 1. Put in style tags and write your body code again. (If you skipped straight to here, I recommend you read the previous layout style guide first, just to get an idea.) This time, remember that the background image is going to tile across the whole page, not only vertically, so you can just put 'repeat' instead of 'repeat-y'. :) 2. I said removal tags cause some complication this time. Here's why: although you can still make the .sf not show up in the same way, since this time the table's going to contain the text, you can't just put 'table {display:none;}', or your text would disappear. The homepage banner is an image within a table which links, so the best you can do is use 'table a img {display:none;}' instead- remember we did combining selectors earlier? Table a img tells the computer to apply the display:none only to images that link and are inside tables, so if you only have text or non-linked images in your table they will be safe. If you're planning to have images that link inside your table, like buttons or banners, it gets even more complex; we'll deal with that soon. 3. Now you write in the actual text table's CSS. Put in what font and colour you want to use, padding, margin and the table width etc., but don't put in the background colour or border code yet- instead, just put background:transparent and border:none. Why? Because in the removal code in step 2, we got rid of the homepage banner, which is an image that links inside a table, but not the actual table. Therefore, if you assign a colour and border now, it'll also apply to the homepage banner table. You can put the colour and border in the HTML later, with style-in-HTML, so it only applies to your text table and not the homepage banner. :) 4. If you are going to use buttons, they won't show up because of the code we added earlier. However, you can fix that by adding another class for your buttons. Call it button or something, and write this:
.button table a img {
display:inline!important; } Or, if you want them to display:block, put that instead. Why this code then? Well, we put display:none earlier, so now if we put display:inline or display:block now, with the !important override, it'll tell any link-images you have within this 'button' div to show up. ;D So wherever you have buttons, all you need to do is put the HTML for the button class and it'll make whatever link-images you put inside show up. 6. Customize the h1, b, i, u, a:link etc. 7. Now it's time to write in the table HTML- I showed you this in the adding HTML section. :) It works much like div HTML, except that you have to remember to put a td and tr tag as well. Remember when we put background:transparent in the table background CSS earlier, to hide the top banner table? Well, you can put your own background colour and border here instead, by putting it in the style-in-HTML. 8. Put in HTML for all the rest of the divs, like navigation and images. You know the drill. (In this layout, if you used a header image, you don't need any CSS for it- you just put it inside the table before your text as a normal image, using the img src and /img tags.) 9. Put your actual stuff in, navigation links, text etc. Save changes and check it's working, and you're done. :)
style 3: textbox with imageFor the textbox layout, the entire page doesn't scroll- only the textbox(es) does. This is actually coded very similarly to continuous text with image- I'm only putting this here as another idea.Images needed: 1. Textbox image. It has to have a textbox, as I'm sure you figured, since this style of layout is called 'textbox with image'. -_- (This one has two, but obviously you can have however many or little you want.)
2. Tileable background image, like the table. This is optional, again, you can just have a plain colour, but a background image always looks nicer. Use a tileable image that matches the background you have in the textbox image. How to code it: This is very similar to the continuous text with image style, as I said- the only difference is that the text div needs a height as well, since it doesn't go down the page infinitely, only in the textbox. Therefore, I won't bother re-iterating every single step. Just remember to add a height for your textbox. :) (Also, remember that because there's no continuous text, and you'll only have a background image for tiling the background, you just put 'repeat' instead of 'repeat-y', just like the table.)
tipsSo now you can code a layout. ;D Whoopee! Here's just a few tips for your future coding endeavours.• Remember that there are lots of different sizes computer screens can be, and also that there are lots of different browsers and computer systems which sometimes display things differently. That just means that if it looks fine on your computer, it might not on somebody else's. ;) Try to avoid that as much as possible by considering smaller and bigger screens and testing it in different browsers- IE, Chrome, FF, Opera and Safari are the main ones. • When you're learning, actually type the codes out, rather than just pasting what I've written here. You learn them much faster. ;) You can also become independent of copying and pasting the codes quicker- I didn't give a whole page code on purpose. When I learnt this, I could only copy and paste premades and edit them, but then I figured out what all the different bits mean and suddenly had a much better grasp of coding, and also how to fix any issues I had. • Putting together a layout, I think, is a bit like solving a maths problem. That sounds ominous, but what I mean is, like, once you know what all the bits do, the thing is to fit them in together, like a jigsaw, so they all work. If something goes wrong, there's probably ways to fix it- use your knowledge of what the bits do to think around problems. • Choose a way to create pages that suit you. I've given you three examples of ways you can do it, but how I do it might not necessarily be how you want to do it. Look at premades and other sites to give you ideas. Once you've got the hang of it, I really really encourage you to type it all out yourself, rather than always using this guide. It's only a crutch, sooner or later you can do without. ;) • If you can't already, learn to make graphics. Just CSS alone is fine, but graphics make it look so much more attractive, in my opinion. I would write a tutorial for graphics as well, if it was possible- but there are so many millions of little things about making graphics, and everyone does it differently, it's so hard to teach someone how to make them in just a petpage. The only way to really learn is just to get an imaging program and experiment- all the images on this page with the exception of the textbox one was made in Gimp, which I used to use and which is free, but Photoshop is even better if you can get it. • A great place to find ideas and learn stuff is premades, and if you like the layout of some random page you find have a good browse in the source code and examine the image. Don't steal, of course, but I used to look over stuff I liked for ages and improve my own skills in the process. thanks!So, thanks for reading. :) I hope you learned something from this guide. xD If you liked it, here's a lovely button with which you can link back to this page:
And if you want to read more of my rambling for some reason, my other guide, Everything Habitarium, can be found here. :)
|
NEOPETS, characters, logos, names and all related indicia
are trademarks of Neopets, Inc., © 1999-2013.
® denotes Reg. US Pat. & TM Office.
All rights reserved.
PRIVACY POLICY | Safety Tips | Contact Us | About Us | Press Kit
Use of this site signifies your acceptance of the Terms and Conditions