Search code examples
htmlcssindentation

CSS p {Indent} Leaving a gap


I am trying to make a website that has a contents page.

I use the <a href="chapter1">go to chapter 1</a> as the contents part, and when it clicks it does to the <a name="chapter1"><u>Chapter 1</u></a>

This works well, but there's 1 catch (there's always a catch)... I want to make it look like the ones on Wikipedia:

[View Image][1] [1]: http://crystalanalysis.anydns.com/images/wikipedia_contents.png

But I didn't want to copy the one from Wikipedia, I wanted to make my own, I looked around, found the parts I needed and had 2 problems! The first problem I am having has something to do with the Indent. I tried using the p.indent {text-indent:150px} but it only did the indent for the line I put it before. So:

Indented text

But it was annoying having to put the Indented text before every single line in the contents box, but it works:

<header>
    p.contenttitle {text-indent:50px;} 
    p.contentsub {text-indent:100px;} 
</header>

<body>
    <div style="background-color:#FFFFFF;width:1024;border:solid 1px #000000;"><br>
    <font class=Blackverdana><b>Contents:</b><br></font>
    <div align="left">
    <!-- CONTENTS a href --><font class=Blackverdana>
    <p class=contenttitle><a href="#C0.1">Chapter 00: First things first...</a>
    <p class=contentsub><a href="#C0.2">Chapter 0.2 Finding the SDK for your game</a>
    <p class=contentsub><a href="#C0.3">Chapter 0.3 Running the Hammer Editor</a>
    <p class=contentsub><a href="#C0.4">Chapter 0.4 First Load</a><br><br>
</body>

The other problem I am having is that if you look at the contents page: http://crystalanalysis.anydns.com/7-12-2013.html

you will see that there seems to be some sort of <br> after every line. I did not plan to have those there, they just appeared. Maybe a connotation with the "p" tag?

Any help would be greatly appreciated

And also the website is a blog and I am making a Hammer Editor Tutorial if anyone was wondering.


Solution

  • So it seems that you aren't ending the

    tags when you first start them.. An example of this:

    <p class=contenttitle><a href="#C0.1">Chapter 00: First things first...</a>
    

    When in all reality it should be:

    <p class=contenttitle><a href="#C0.1">Chapter 00: First things first...</a></p>
    

    That could be a possible issue, as well as you should really look into using a CSS page to reference your HTML. Creating a class/id will actually make that indentation process ten times easier. For more information on that I can provide a handy link from w3.org that can explain the entire process of using CSS and how it can make your life a lot easier!

    http://www.w3.org/Style/Examples/011/firstcss.en.html