This text is aligned left. This isn't really necessary to put into tags because it is the forum default. If you don't specify an alignment, it will automatically be to the left. Notice how on the left side the text looks pretty uniform, but how the right edge is a little bit scraggly.
This text is aligned right. This is not the forum default, so you will need to use tags for this. Notice how on the right side the text looks pretty uniform, but how the left edge is a little bit scraggly. Any line that isn't a full line will be pushed to the right of your post.
This text is aligned center. This is not the forum default, so you will need to use tags for this. Both sides will be scraggly, and any line that isn't a full line will be put in the center of the post.
This text is aligned justify. See how it looks very straight and uniform? This is not the forum default, however it is what I use for the majority of this tutorial! It's also what I use for the majority of my posts. Any line that is not a complete line will be pushed to the left for this also.
Okay, so how'd I do that? It's super easy. Your code will look something like this (keeping in mind <> vs []):
So, thinking back to chapter 1, our tagname is "div" which matches the end tag. Our attribute is "align" because that's what we're trying to change, and our value is that bolded spot where it says "alignment". That's where you put either "right", "center", or "justify" depending on what you want. You really don't need to do this if you want it left because it is the forum default. So just as an example, if you want your text to be centered, your code would look like this:
<div>This is my first div!</div><div>this is my second div! I didn't even hit enter!</div>
will look like
This is my first div!
this is my second div! I DID hit enter!
Even tho I only hit enter 1 time, since the div tag automatically adds a line break when you start it, it comes out as two line breaks.
Text is not the only thing that can go in a div. images, other divs (remember our chat about nesting?), and just giant hunks of space are all fair game also.
Width & Height
Let's actually start thinking about how we want our template to look. We've already talked about alignment. Most people want the bulk of their template to sit in the center of the post, so there we have our first attribute and value.
<div align="center"> </div>
A very good idea is to determine the
width that you want for your template. The width is how wide your template is going to be. If you don't set the width, your div will just stretch to whatever width the text makes it. In some cases that's fine, but usually we want to set a width. You can set your width in pixels (px) or in percentage (%). If you use percentage, it will be based off of the width of whatever the div is inside of. So if the div is alone, it will be a percentage of the board itself. If it's inside another div, it will be a percentage of the original div. So if you set it for 100%, it will take up 100% of the board area (or whatever div it's in) width wise. If you set it to 50% it will take up 50%, etc.
While I prefer percentages for coding literally anything else, I like to use pixels for my templates. To me, it just makes things easier because different boards on different sites have different widths, and that will effect how your template looks if you use it across different sites. Not to mention it will take more calculating to figure out percentages. Pixels are uniform. 9/10 times, you'll want to use pixels. Unfortunately I have no good way to help you know how big a pixel is - you'll just have to experiment.
Height is a little more lenient. I personally like to set heights because I'm very picky but some people don't. If you don't, the height will just stretch as far as your content needs. No big deal. Once again, though, let's stick with pixels.
Remember in chapter 1 when I said you can have more than one attribute? Let's take our template div we have so far (the one we centered) and add some more attributes for our width and height.
<div align="center" width="200px" height="500px"> </div>
Notice how I only put the tag name once! Each attribute gets the equal sign and double quotes around the value. "px" means pixel, and like I said I'm picky about height but maybe you're not. So let's look at it:
You're probably thinking, "um overlord there isn't anything there" and to that I say you are absolutely correct. All of that blank space is supposed to be your div (and since empty divs are invisible blocks like I said earlier it's really just a little shorter than it should be), but for some reason proboards doesn't like it when I use multiple attributes like I SHOULD be able to -shakes fist at proboards-
But that's okay because that actually segues quite nicely into our next topic.
Styles, Properties, and Values
If we were to use an individual attribute for each thing we wanted to modify for our div our code would be so long, especially for highly stylized templates. Luckily, there's a shortcut that works really nicely on proboards called the
style attribute. Essentially, when you use the style attribute you're just taking all of the attributes you wanted to use and shoving them all into one. It will look something like this:
<div style="property:value;"> </div>
"
style" is your new attribute. Your
property is basically your old attribute, i.e. width, just in a different spot, and your
value is pretty much the same as before. Pay special attention to the double quotes and the semi-colon. They are super important. A semi-colon goes after each property/value set, including the last one. So let's use our original width and height as an example.
<div align="center"><div style="width:200px;height:500px;"> </div></div>
Okay, at this point you probably think I'm crazy. I know it doesn't look like anything is there, but trust me, it is. Remember - divs are invisible until you modify them either in the style tags or by putting something in the content.
Now, why did I put that alignment property in its own div? Well, you need to remember that a div style only modified what's
inside the div. So, in order to center the entire template itself, and not just what's inside of the template, you have to put an extra div around it.
Background Color
So let's do just that. Let's modify the
background color of our div. We do this by adding a "background-color:#xxxxxx;" property value set.
A pound sign followed by 6 numbers/letters is how you tell the computer to show a certain color. There are various websites you can use, but I like to use WEBSITE NAME HERE. If you plan to do a lot of graphic-y stuff, I also recommend the browser extension NAME HERE. I really like the color #ccccff, so I'm going to use that for our background:
<div align="center"><div style="width:200px;height:500px;background-color:#ccccff;"> </div></div>
Becomes
Okay! So now that we can actually see our div, I think I might want to change up the dimensions a little bit. To me, it seems a little too thin and too tall to be a regular posting template. Let's try a 400x500 size. So here's our code:
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"> </div></div>
And our template so far:
Text Color, Font, & Size
Some people like to put quotes in their templates and that's just what I'm gonna do. I'm going to use the quote "She needed a hero, so that's what she became." I'm going to split it between the top and the bottom. First, let's just see what it looks like when we just sorta pop the first half in there.
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;">she needed a hero</div></div>
And our result...
... Is kind of uggie. Or at least it's very plain looking. So how do we fix that? MORE STYLE TAGS. now here is where we need to make a big decision..... Do we just add more property/value sets to the one we already have? Or do we make ENTIRELY NEW TAGS and nest it inside?
Well let's think. I want the quote to be big, but the other text for the actual post to be sort of small. And I think I want the big text to be a pink color, but the little text to be white. And I think I even want the big text to be a different font all together. So since I want the big text to be so much different from all the other text, I'm going to start a new div that ONLY surrounds the text that it's going to modify. Don't forget to add another closing tag!
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div>she needed a hero</div></div></div>
It's always a good idea to change the color and the font before you pick a size so that you know exactly what you're working with. Sometimes different fonts are different sizes even tho they say they're the same size, so it can cause trouble and frustration if you pick the size first. I like the color #cc8acc. Let's try that. To change font color, you just add a
"color:#xxxxxx;" just like with the background color.
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;">she needed a hero</div></div></div>
To change the font, you use
"font-family:'specific name', generalfamily;"Okay, lets pause before I show you that example. Where it says specific name, you want to put the name of the font itself, such as times new roman or comic sans. If it's more than one word, you need SINGLE quotes, not double!!! Hell even if it's one word I still put the single quotes in. Then you need a comma, and then you need to put a
general family name as a back up in case your computer doesn't recognize the font you chose. That way, it at least knows you want it to look a certain way, and it'll try its best to get as close as possible.
If you want to be completely, 99.99% sure that the font you picked will show up on every computer ever, it's a good idea to use a
websafe font. That link includes an entire list of fonts you can use that will more than likely show up on every computer, and the general family name you can list them under. For Anrui specifically, we also have
some Google fonts installed that you can use also.
So for example I'm going to use the font named Miniver. Since I'm going for a cursive look, I'll use cursive as my general family name.
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;">she needed a hero</div></div></div>
Okay. Let's check that.
Yes, we are getting better. Let's mess with the
font size by using our
"font-size:00px;" set.
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div></div></div>
Just like with the width and height, we measure our font in pixels on proboards. So let's try that and see how much of a difference we have.
Looking good! Now because we want the main body of the post to be styled differently than default also, we need to add another div to style.
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div><div>main text will go here!</div></div></div>
she needed a hero
main text will go here!
Awesome. Remember, even though we didn't hit the enter key, it still put a line break because we started a new div.
So I don't think I want to change the font family for my main text. The one we have as the default is very readable on computers and tablets, and I don't want my template to look too clashing. I do, however, want to change the font color, and possibly the size. Let's go with dark blue to contrast the light background. I'm going to add in my color property set, and also some dummy text so I can really see what it will look like as an actual post.
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div><div style="color:#595987;">They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?</div></div></div>
she needed a hero
They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?
That doesn't look too bad. Let's make the font a little bigger, and then also I think I want this text to be justified. So I can either add a new div like we did earlier, or I can use the
text align property set since I'm modifying what's INSIDE the div. Let's do that:
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div><div style="color:#595987;font-size:14px;text-align:justify;">They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?</div></div></div>
she needed a hero
They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?
Okay so now it's justified and at a readable size, but not only it is squeezed all the way to the edges of the template, but we also don't have room for our ending quote! We can fix this in a multitude of ways, but I'm going to do the simplest method and just change the width and the height.
im also going to be just putting "dummy text" instead of the entire two paragraphs so that these posts don't get too stretched.<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div><div style="width:300px;height:350px;color:#595987;font-size:14px;text-align:justify;">dummy text </div></div></div>
she needed a hero
They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?
Well, we've fixed our problem of being right up against the edge, but now our text is too long to the point where it's actually coming out the bottom of the template! It does this when the amount of text in a div is more than what can fit in a particular height and width. We can fix this by either removing both of the div's height values so that the entire template becomes stretched, or we can add a scroll.
To Scroll, or Not to Scroll?
So first let's look at the code and template when I removed the heights.
<div align="center"><div style="width:400px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div><div style="width:300px;color:#595987;font-size:14px;text-align:justify;">dummy text </div></div></div>
she needed a hero
They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?
There's still no room for the ending quote, but because there's no height set, we can still add it in and it will just stretch. Overall, not a bad option.
You can also had a scroll bar using the
overflow property set. If you want the scroll bar to be there regardless of whether or not it's needed, you just use "scroll" for your value. If you want it to only be there when it's needed, you use "auto" for your value. So let's put the heights back in and use auto for our example.
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div><div style="width:300px;height:350px;color:#595987;font-size:14px;text-align:justify;overflow:auto;">dummy text </div></div></div>
she needed a hero
They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?
Either option is fine! I'm going to stick with the scroll, just because that's what I prefer.
So now to add our end quote, since I want it to be styled the same way as the first part, I can just copy and paste!
<div align="center"><div style="width:400px;height:500px;background-color:#ccccff;"><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">she needed a hero</div><div style="width:300px;height:350px;color:#595987;font-size:14px;text-align:justify;overflow:auto;">dummy text </div><div style="color:#cc8acc;font-family:'Miniver', cursive;font-size:16px;">so that's what she became</div></div></div>
she needed a hero
They're creepy and they're kooky mysterious and spooky. They're all together ooky the Addams Family. Thank you for being a friend. Travelled down the road and back again. Your heart is true you're a pal and a confidant. Straightnin' the curves. Flatnin' the hills Someday the mountain might get ‘em but the law never will. You wanna be where you can see our troubles are all the same. You wanna be where everybody knows Your name. we might as well say... Would you be mine? Could you be mine? Won't you be my neighbor.
Till the one day when the lady met this fellow and they knew it was much more than a hunch. The year is 1987 and NASA launches the last of Americas deep space probes. These days are all Happy and Free. These days are all share them with me oh baby. The mate was a mighty sailin' man the Skipper brave and sure. Five passengers set sail that day for a three hour tour a three hour tour. Michael Knight a young loner on a crusade to champion the cause of the innocent. The helpless. The powerless in a world of criminals who operate above the law. Today still wanted by the government they survive as soldiers of fortune. Why do we always come here? I guess well never know. Its like a kind of torture to have to watch the show?
so that's what she became
And there's our template! Now like I said in the beginning, this template is the bare basics. It's readable, and it's styled. Does it look the best? Nah. There is definitely more id do to it to make it even better. But it works. We'll be covering more stuff in the next few chapters, and I'd love to see what you can do with THAT information to make THIS template better ;3