Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Introduction Global Structure: Part 2

localhost?

When I open my index.html file with the browser, I get all of the code. I don't get "This is a div." I feel like I missed a step, but can't figure out what it is. What am I missing?

David Lane
David Lane
33,414 Points

Please post your code, we need to see your markup to figure out the problem.

Here's the code:

<!DOCTYPE html>

<html lang=β€œen”> <head> <meta charset=β€œutf-8”> <title>My Page</title> </head> <body> <div>This is a div.</div> </body> </html>

To put it another way, when I refresh localhost, it does not change to My Page.

David Lane
David Lane
33,414 Points

What type of localhost are you running? When done in MAMP, your code produces a blank page that says "This is a div." with a title of "My Page".

I don't know. I'm just following the HTML tutorial: open localhost in chrome, create and save index.html, refresh localhost, and for me, nothing happens. I am using a mac. Do I need to set up, download, or switch on something? It is not covered in this track.

I think my next step will be a google search on setting up localhost on a mac running os x.

Maybe the problem comes from not having opening and closing <html> tags.

Try

<!DOCTYPE html>
<html>
(YOUR CODE)
</html>

Nope, already has the opening and closing tags.

I found instructions online that recommended putting index.html into a Sites folder in Home, instead of on the desktop. Now, when I go to localhost it does go directly to index.html, but it still just displays the code instead of rendering a page according to the html in the code.

Hi! I believe your problem could be that you don't have your index.html in the right directory, or even a web server like apache installed.

But you don't need that to start learning and testing html! Simply open that index.html file with a browser and everything should be working fine. At that point you can call your html what ever you like, as long as it has .html extension.

1 Answer

Yeah, I used a browser to do it.

I'll check to see if updating my OS uninstalled Apache. I hadn't thought of that.