Search:

Home | Free Software | Wordpress


Formatting Text in Wordpress

By: Deceth

I've received several questions relating to yesterday's tutorial, "Your First PHP Page" in regards to how I was able to include HTML code in my post. For example, if you want to make a word bold, you type <strong>bold</strong>. So the question is, how then did I write <strong>bold</strong> without the word becoming bold? The other questions I've been asked is, "How the heck did you do that indentation?!".

First, I'd just like to say it's really interesting how you can write a hot topic accidentally! My post yesterday was geared at providing a very basic PHP tutorial, but ended up stirring interest amongst bloggers who would like to have more control over the formatting of their posts! Please keep the feedback coming as I am very eager to answer any and all such questions!

The magic behind yesterday's post is actually very simple. Writing a post in Wordpress is a simplified way of inserting a few paragraphs of HTML formatted text into a web page. When you make a word bold or add a link, the text is surrounded by tags which will tell the browser how to format it's appearance on the screen. HTML tags always begin with "<", so as soon the browser encounters this symbol, it will check to see if it is a valid HTML tag, and if so, take the appropriate actions. If you actually just want to display the "<" symbol on screen and have the browser ignore the possibility that it could be HTML code, then you need to instead write the ASCII entity name.

I know many of you just grumbled and felt discouraged at the mention of ASCII entity names, but don't worry I promise it really is very easy! Basically, all you need to know is that some characters have an ASCII entity name which you can type in your posts to display the character. For example, the ASCII character name for < is:

&lt;

Try it out! Open up wordpress and type the above ASCII character. When you preview the page, you will see that the character < is displayed instead. The new mystery then is, how did I write the ASCII character above without it being turned into "<"? hmmm...!



The next question was related to indentation in posts. The first thing I did was put my code within a blockquote. If you are using Wordpress, you can simply highlight text, then click the "b-quote" button to do this. This indents a whole paragraph of text, commonly used for quoting references by bloggers. Next, I surrounded my blockquote with a tag called <pre></pre>. This tag is used to define preformatted text which means that the text enclosed between the tags will be displayed as it is typed. In a nutshell, if you are typing a post in Wordpress and hit the spacebar 20 times between each word, when you hit preview, it will still only show a single space between each word. However, if you use <pre>text to be preformatted here</pre> in your post, then all text between the tags will display your text as it was written, meaning multiple spaces can be displayed.

Try it out. Copy/Paste the below into Wordpress and preview it to see the effect:

<pre> This is the first line, with no indent.
This line has 5 spaces in front of it!
This line has 10 spaces in front of it!
</pre>

Enjoy!

Article Source: http://www.writerdatabase.com

www.webdevnotes.com/formatting-text-in-wordpress/

Please Rate this Article

 

Not yet Rated

Click the XML Icon Above to Receive Wordpress Articles Via RSS!

Powered by Article Dashboard