• We just launched and are currently in beta. Join us as we build and grow the community.

How to make a simple footer in HTML/CSS

vtrippy

Paywall Strategist
V Rep
0
0
0
Rep
0
V Vouches
0
0
0
Vouches
0
Posts
76
Likes
62
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Introduction:
This tutorial will be a code sample of a footer in CSS.

Steps of Creation:
Step 1:

First we need a HTML file to contain our footer. I have created one with a couple of divs and a link to my theme.css CSS file.

Visit us at http://www.sourcecodester.com.

Step 2:
Now lets set the default settings for our html file in our theme.css.

  1. *

    {
  2. margin

    :

    0px

    ;
  3. padding

    :

    0px

    ;
  4. color

    :

    #fff

    ;
  5. }

  6. body{
  7. width

    :

    100%

    ;
  8. }

Step 3:
Next I have set a height for my fake div so it shows up properly...

  1. .contentFake{
  2. background-color

    :

    #333

    ;
  3. height

    :

    770px

    ;
  4. }

  5. .footer{
  6. width

    :

    100%

    ;
  7. position

    :

    fixed

    ;
  8. margin-bottom

    :

    0px

    ;
  9. height

    :

    80px

    ;
  10. background-color

    :

    #1A1A1A

    ;
  11. display

    :

    block

    ;
  12. }

  13. .footerContent{
  14. width

    :

    80%

    ;
  15. margin

    :

    auto

    ;
  16. padding

    :

    5px

    ;
  17. text-align

    :

    center

    ;
  18. border-left

    :

    1px

    solid

    #fff

    ;
  19. border-right

    :

    1px

    solid

    #fff

    ;
  20. }

For our footer we have set it fixed to the bottom of the screen with a 80px height, 100% width and a slightly different colour to our main background to differentiate it. I have also given my footerContent a border on the left and right sides and given it a slightly smaller width.

Project Complete!
Below is the full source and download to the files.

Visit us at http://www.sourcecodester.com.

  1. *

    {
  2. margin

    :

    0px

    ;
  3. padding

    :

    0px

    ;
  4. color

    :

    #fff

    ;
  5. }

  6. body{
  7. width

    :

    100%

    ;
  8. }

  9. .contentFake{
  10. background-color

    :

    #333

    ;
  11. height

    :

    770px

    ;
  12. }

  13. .footer{
  14. width

    :

    100%

    ;
  15. position

    :

    fixed

    ;
  16. margin-bottom

    :

    0px

    ;
  17. height

    :

    80px

    ;
  18. background-color

    :

    #1A1A1A

    ;
  19. display

    :

    block

    ;
  20. }

  21. .footerContent{
  22. width

    :

    80%

    ;
  23. margin

    :

    auto

    ;
  24. padding

    :

    5px

    ;
  25. text-align

    :

    center

    ;
  26. border-left

    :

    1px

    solid

    #fff

    ;
  27. border-right

    :

    1px

    solid

    #fff

    ;
  28. }

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.

2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

336,529

336,537

Top