Toag
Toag

Reputation: 3

HTML5 Div Style Not Working

I'm new to programming, and I got a book for Canvas in HTML5 for Christmas. It's starting off small, but I'm a little worried that I can't get one of the examples in it to work. I've copied it word for word, tried it in several different browsers, and it still won't work. It's supposed to move the words "Hello World" 50px down and right, but it keeps it in the regular (0,0) position at the top left. Any help please?

<!doctype html>
<html lang=“en”>
<head>
<meta charset=“UTF-8”>
<title>CH1EX2: HTML Hello World Page With A DIV</title>
</head>
<body>
<div style=“position: absolute; top: 50px; left: 50px;”>
Hello World!!
</div>
</body>
</html>

Thanks in advance.

Upvotes: 0

Views: 116

Answers (3)

xxbbcc
xxbbcc

Reputation: 17327

Your double quotes look like they're what's called "smart quotes" - linguistically appropriate double quotes instead of the straight " symbol. You're probably using a document editor like Word or something similar. While you can turn this behavior off in Word, it's just better to use a plain text editor for editing code. Here are a few free ones (assuming you're using Windows):

There are more - they all are all common in that they don't format the text you're working with - they keep the plain text unchanged, unlike WYSIWYG editors.

Upvotes: 0

Musa
Musa

Reputation: 97672

Your quotes are wrong, you have to use " or ' quotes

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CH1EX2: HTML Hello World Page With A DIV</title>
</head>
<body>
<div style="position: absolute; top: 50px; left: 50px;">
Hello World!!
</div>
</body>
</html>

http://jsbin.com/UKEsIji/1/

Upvotes: 2

Z .
Z .

Reputation: 12837

I'm pretty sure those are the wrong type of double quotes. Yours need to look like this "

Upvotes: 2

Related Questions