Formatting Text - Chapter 2
Formatting Text
You can also format your text to emphasize certain words. Before we talk about that, let’s revisit something we covered in the last exercise. HTML allows you to add breaks in your content by using certain elements. When you use the <p> </p> element, the text following the element is automatically started on a new line. The same thing is true for the <h1> </h1> element—if you use a heading element, the information following it will automatically be started on a new line, these are called block elements.
If you want to start something on a new line, there has to be a command (or element) to tell the browser to do so. It won’t just happen if you hit the return button in your code. The browser will simply ignore the whitespace you created and only do what it is told to do through the elements you write.
So if you want to add a break in a section of text you can use the:
<br>You can also use the horizontal rule element to add a
line to help section off your page: <hr>
Now when it comes to formatting text, there are a variety of things you can do. You can make text bold, or make it italicized...highlight it, etc. There is a great amount of flexibility you have with HTML and even more flexibility with CSS (Cascading Style Sheets), which we will talk about in a later course.
To make a word bold, for example, you would write:
<p> In this section I am going to write a word in<b>bold.</b> </p>
It would come out in your browser’s window as:
In this section I am going to write a word in bold.
Everything that’s between the <b> and the </b> will be shown in bold.
In the same way, you can make words italicized or highlighted, etc. This formatting can be added within other elements, such as within the <p> </p> element. Elements that don’t start subsequent content on new lines are called inline elements (<b></b> is an inline element).
In HTML, this is how you write these elements:
<b> Text goes here </b>
<i> Text goes here </i>
<mark> Text or paragraph goes here </mark>
For example:
<p> This sentence will include a word that is
<i>italicized</i> </p>