making a simple layout

CRASH COURSE TUTORIALS — learn how to code!
making a simple layout
GLOSSARY
div
margin
padding
height
width
line-height
overflow
text-align

today, i'm going to teach you how to make this layout:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec feugiat tempus lectus eu faucibus. Morbi vel mauris vitae dolor egestas accumsan. Mauris sed tellus porttitor, posuere neque in, euismod odio. Integer et arcu sed justo dictum convallis.

whenever i make a new layout, i open up a new blog post. that way, i can code and view the preview without actually adding another chapter on accident. let's familiarize ourselves with the AFF editor. we'll be working with the following button the most:

clicking the button on the left will enable you to see the source code, while the button on the right gives you a preview in another window.

when coding a layout, you're going to be working with the div and span tags most of the time. i've already taught you about the span tag, but for many of you, it's the first time you've seen the div tag. the div tag makes up the basis of all your layouts, and how things look.

there are many attributes in the style section of a div:

margin: sets how many pixels of space between the div and other content
    — top right bottom left [10px 60px 15px 80px]
padding: sets how many pixels of space between the div and the contents inside
    — top right bottom left [ 8px 12px ]
height and width: sets the height and width
    — can be in pixels (500px) or percentage (80%)
background color: sets the background color of a div
border: sets the border of a div
    — thickness type color [2px dashed #999999]
line-height: sets the line spacing of the text inside
    — can be in pixels (12px) or a decimal number (1 or 1.5)
text-align: sets the alignment of the text inside
    — left, center, right, or justify

to start out with our sample layout, i chose a small width and height, going with 150px by 80px. the background color i chose is #f5a68a. let's start coding!

< div style="width:150px; height:80px; background-color:#f5a68a;" >hello this is a bunch of sample text. i wonder how this will turn out! < /div >

hello this is a bunch of sample text. i wonder how this will turn out!

the size looks fine, and the background color is good—but let's add some padding and customize the text!

< div style="width:150px; height:80px; background-color:#f5a68a; padding:15px;" >< span style="font-family:arial; font-size:9px; letter-spacing:1px; color:#ffffff;">hello this is a bunch of sample text. i wonder how this will turn out!< /span >< /div >

hello this is a bunch of sample text. i wonder how this will turn out!

it's important to note that using padding ADDS width and height to your div. since we added 15px on each side, 30px has been added to the dimensions (now 180px by 110px).

let's tweak the line-height a little bit and add some more text. i always use this website when i need to add some placeholder text.

< div style="width:150px; height:80px; background-color:#f5a68a; padding:15px; line-height:11px;" >< span style="font-family:arial; font-size:9px; letter-spacing:1px; color:#ffffff;">hello this is a bunch of sample text. i wonder how this will turn out! lorem ipsum dolor sit amet, consectetur adipiscing elit. donec feugiat tempus lectus eu faucibus. morbi vel mauris vitae dolor egestas accumsan. mauris sed tellus porttitor, posuere neque in, euismod odio. integer et arcu sed justo dictum convallis.< /span >< /div >

hello this is a bunch of sample text. i wonder how this will turn out! lorem ipsum dolor sit amet, consectetur adipiscing elit. donec feugiat tempus lectus eu faucibus. morbi vel mauris vitae dolor egestas accumsan. mauris sed tellus porttitor, posuere neque in, euismod odio. integer et arcu sed justo dictum convallis.

 

 

 

 

we've run into a problem—the text flows out of the box! i'm sure this is what many of you face. to fix this problem, we're going to use the overflow attribute and set it to auto. this enables users to scroll to see more text.

< div style="width:150px; height:80px; background-color:#f5a68a; padding:15px; line-height:11px; overflow:auto;" >< span style="font-family:arial; font-size:9px; letter-spacing:1px; color:#ffffff;">hello this is a bunch of sample text. i wonder how this will turn out! lorem ipsum dolor sit amet, consectetur adipiscing elit. donec feugiat tempus lectus eu faucibus. morbi vel mauris vitae dolor egestas accumsan. mauris sed tellus porttitor, posuere neque in, euismod odio. integer et arcu sed justo dictum convallis.< /span >< /div >

hello this is a bunch of sample text. i wonder how this will turn out! lorem ipsum dolor sit amet, consectetur adipiscing elit. donec feugiat tempus lectus eu faucibus. morbi vel mauris vitae dolor egestas accumsan. mauris sed tellus porttitor, posuere neque in, euismod odio. integer et arcu sed justo dictum convallis.

thankfully, we can now see the rest of the text! we've just got one thing left to do: make the div centered! to do that, i use margin-left and margin-right and set it to auto. setting BOTH the left/right margins to auto makes sure the box is centered. lastly, i'm simply making the text aligned to justify.

< div style="width:150px; height:80px; background-color:#f5a68a; padding:15px; line-height:11px; overflow:auto; margin-left:auto; margin-right:auto; text-align:justify;" >< span style="font-family:arial; font-size:9px; letter-spacing:1px; color:#ffffff;">hello this is a bunch of sample text. i wonder how this will turn out! lorem ipsum dolor sit amet, consectetur adipiscing elit. donec feugiat tempus lectus eu faucibus. morbi vel mauris vitae dolor egestas accumsan. mauris sed tellus porttitor, posuere neque in, euismod odio. integer et arcu sed justo dictum convallis.< /span >< /div >

lorem ipsum dolor sit amet, consectetur adipiscing elit. donec feugiat tempus lectus eu faucibus. morbi vel mauris vitae dolor egestas accumsan. mauris sed tellus porttitor, posuere neque in, euismod odio. integer et arcu sed justo dictum convallis.

and there we have it! our first layout together :'-) i hope this tutorial was helpful to all of you! thanks for checking out crash course tutorials! upvote and subscribe for more updates.

Like this story? Give it an Upvote!
Thank you!

Comments

You must be logged in to comment
lilico
#1
is this still a thing : ))
PMEroleplay #2
Chapter 5: Please make tutorials on:
*how to put text on pictures
*how to link pictures to websites
*how to make text boxes that scroll
*more general basics

thank you ^~^
velvetred #3
omg i love this
john green and hank green < 3
-mrchuu
#4
Chapter 2: eue, I have a question...
You know how sometimes the layout overlaps in the comment section?
Why does that happen and how do you change it?

btw. I like your layouts. Tbh, sometimes, people who do layout tutorials make their layout all fancy and cute so you can't read anything nevertheless learn how to use the tutorial OTL
Yours is simple and nice :3
MickeyC7914
#5
Chapter 2: these are so helpful, thank you so much!
BestFriend18
#6
Chapter 2: update soon please.... /puppy eyes
I need your another tutorial^^
-Daezed-
#7
Chapter 2: please update soon ^^;
--starlightmelody
#8
Amaaaazing C:
Thanks for doing a layout tutorial~
May I request? I've been seeing layout with text on boxes, at first I thought it was picture with margin, but wrong, then I found that it can have borders~! Could you please do a tutorial about that? Thanks ^^
toukyo #9
Chapter 2: i can't put the text overlapping the image for some reason
toukyo #10
Chapter 2: just found this tutorial