Leak Society - The Home Of Nulled Resources.
Forum Beta v1 Now Live!
[Tutorial] How to start a HTML webpage! Part 4
Thead Owner : Lord Royal, Category : Everything Coding, 2 Comment, 19 Read
Viewers: 1 Guest(s)
Senior Member
****
647
Messages
101
Threads
0
Rep
4 Years of Service
02-22-2014, 11:33 PM
#1
Paragraphs

Now that you have the basic structure of an HTML document, you can mess around with the content a bit.

Go back to your text editor and add another line to your page:


<!DOCTYPE html>
<html>
<head>
<title>My first web page</title>
</head>
<body>
This is my first web page
How exciting
</body>
</html>
Look at the document in your browser.

You might have expected your document to appear as you typed it, on two lines, but instead you should see something like this:

This is my first web page How exciting.

This is because web browsers don’t usually take any notice of what line your code is on. It also doesn’t take any notice of spaces (you would get the same result if you typed “This is my first web page How exciting”).

If you want text to appear on different lines or, rather, if you intend there to be two distinct blocks of text (because, remember, HTML is about meaning, not presentation), you need to explicitly state that.

Change your two lines of content so that they look like this:


This is my first web page

How exciting

The p tag is used for paragraphs.

Look at the results of this. The two lines will now appear on two lines because the browser recognizes them as separate paragraphs.

Think of the HTML content as if it were a book - with paragraphs where appropriate.

Emphasis

You can emphasize text in a paragraph using em (emphasis) and strong (strong importance).


Yes, that really is exciting. Warning: level of excitement may cause head to explode.

Traditionally, browsers will display em in italics and strong in bold by default but they are not the same as i and b tags which (although they have been tenuously redefined in HTML5) have their origins in italic and bold - remember - HTML isn’t for presentation. If you want to emphasize something visually (making something italic, for example), you almost certainly want to give it general emphasis. You can’t speak in italics.

Line breaks

The line-break tag can also be used to separate lines like this:


This is my first web page

How exciting
There’s no content involved in breaking lines so there is no closing tag.

It could be tempting to over-use line breaks and br shouldn’t be used if two blocks of text are intended to be separate from one another (because if that’s what you want to do you probably want the p tag).


Messages In This Thread
[Tutorial] How to start a HTML webpage! Part 4 - by Lord Royal - 02-22-2014, 11:33 PM
[Tutorial] How to start a HTML webpage! Part 4 - by Guest - 02-22-2014, 11:35 PM

Forum Jump: