How to Align Text in HTML

When HTML and the Internet were first developed, they were for sharing of text only. No one expected to be able to make fancy web pages with images, videos and other content. Instead, there was just text, and it didn't matter how it looked, as long as you got the right text. Since that time, the Internet has changed a lot. However, the basics behind sending information, plain text, have not changed a lot. To align your text is not what the Internet was made to do, but you can align your text in a few different ways now.

Things You'll Need

  • Simple text editor or HTML editor
Show More

Instructions

    • 1

      Put your text in a container. To align text, it must be contained in something. The simplest container is a paragraph. Text contained in a paragraph will appear between a begin paragraph tag, <p>, and an end paragraph tag, </p>.

    • 2

      Add an alignment attribute. All HTML tags are allowed to have attributes in them. This is the text that appears after a space in the tag. To set up alignment in a paragraph tag, you use the align tag. It will look like this so far: <p align

    • 3

      Add a value for your attribute. As with all other HTML tags, your attribute can be followed by a value. In this case, the value will be "center," which will center your text in a paragraph. Always use an equal sign between all attributes and values. The tag should now look like this: <p align=center>

    • 4

      Use CSS to align your text. If you are using a different type of container, such as a span or div, you will need to use style sheets and CSS to align your text. In this case, you will need to write code in your style sheet. If this is an in-line style sheet, your CSS will be via a style attribute, like this: <span style=

    • 5

      Add the text-alignment style. Inside your style sheet, to center your text, add the style "text-alignment:center." Your in-line style sheet might look like this: <span style='text-alignment:center;'>

Tips & Warnings

  • Use style sheets when you can, as they are more effective and useful.

Related Searches

You May Also Like

Related Ads

Featured
View Mobile Site