Lines and Breaks
Have you noticed that whenever you use the <p> tag or any of the header tags, the browser puts a space between the contents? This helps to break up the paragraphs visually, making it easier to read. But what if you don't want that break? What if you want to have the text on different lines, but without all that space - say like an address:
Google
1600 Ampitheatre Parkway
Mountain View, CA 94043
The way to do this is with the break tag. The break tag looks like this: <br>. To write the address above, you would use:
<p> Google<br> 1600 Ampitheatre Parkway<br> Mountain View, CA 94043 </p>
If you look closely, you might notice something a little different about the break tags: They don't have closing tags! That's because there is no text contained inside a break. It's just there.
In HTML, tags that have content inside them, like the paragraph and header tags, need opening and closing tags. But tags that have no content inside don't use closing tags.
Another way to separate content is with a horizontal line. The tag for this is <hr>, which stands for horizontal rule. Using an <hr> tag looks like this:
Using these lines, along with the other tags you now know, you should now be able to create well-organized, easy to read HTML documents:
<html> <h1>The Solar System</h1> <p>The Solar System consists of eight planets*. These planets all travel in circles around the sun. The four planets closest to the sun, known as the inner planets, all have hard surfaces and either no atmosphere or an atmosphere of relatively thin gasses. The four outer planets, because of their distance from the sun, have atmospheres made mostly of liquified gasses, and are known as gas giants</p> <h2>The Inner Planets</h2> <p>The four inner planets are: Mercury, Venus, Earth, and Mars. They are all close enough to the sun to have gaseous atmospheres, although Mercury is so small that it has almost no atmosphere at all. All four of the inner planets have a solid, almost spherical crust.</p> <h2>The Outer Planets</h2> <p>By contrast, the outer planets have thick atmospheres of gasses such as Hydrogen, Helium, or Methane. These planets are so cold that these gasses are all in liquid form.</p> <hr> <h3>Notes:</h3> <p>* Pluto used to be considered the ninth planet, until the International Astronomical Union changed the definition of a planet in 2006. Now, we have eight planets and three dwarf planets:<br> Pluto<br> Ceres<br> Eris</p> </html>
This page would look like this:
« Prev: Headers and Text Next: Lists »