Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning HTML, XHTML, CSS, and JavaScript
This is the forum to discuss the Wrox book Beginning HTML, XHTML, CSS, and JavaScript by Jon Duckett; ISBN: 978-0-470-54070-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning HTML, XHTML, CSS, and JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 9th, 2010, 12:43 PM
Registered User
 
Join Date: Sep 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie Basics

Just tried to set up the first elements from chapter 1 in the text editor on my mac, when I opened it in Safari 5 it showed me all my code - looked great, but not what I was looking for. I shot it over to my pc and it's formatted exactly like I expected it to be (and as the books shows) in IE. Should I not be trying to learn html on a mac? I understand different browsers format differently, but there was no formatting involved in the page Safari opened, just strait code. What really simple element am I missing?
Reply With Quote
  #2 (permalink)  
Old September 10th, 2010, 02:00 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Show us the code you tried. It should work *basically* the same in all browsers. Yes, there are browser incompatibilities, but they are usually much more subtle than this.
Reply With Quote
  #3 (permalink)  
Old September 10th, 2010, 02:31 PM
Registered User
 
Join Date: Sep 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, here goes, I copied everything directly out of the book. Since my original post I've installed Firefox on the mac and opened it there as well, just getting code. thanks!

<html>

<head>
<title>Example Cafe - community cafe in Newquay, Cornwall, UK </title>
</head>

<body>
<h1>EXAMPLE CAFE</h1>
<p>Welcome to example cafe. We will be developing this site throughout the book.</p>

<h2>A community cafe serving home cooked, locally sourced, organic food</h2>
<p>With stunning views of the ocean, Example Cafe offers the perfect environment to unwind and recharge the batteries.</p>

<p>Our menu offers a wide range of breakfasts, brunches and lunches, including a range of vegetarian options.</p>

<p>Whether you sip on a fresh, hot coffee or a cooling smoothie, you never need to feel rushed - relax with friends or just watch the world go by.</p>

<h2>This weekend's special brunch</h2>
<p>This weekend, our season of special brunches continues with scrambled egg on an english muffin. Not for the faint-hearted, the secret to these eggs is that they re made with half cream and cooked in butter, with no more than four eggs in the pan at a time.</p>
</body>
</html>
Reply With Quote
  #4 (permalink)  
Old September 10th, 2010, 02:40 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I think I can guess the problem. I'm not a Mac user, but you can have similar problems with trying to use certain pages on IE.

I'm *guessing* that you need to use a WEB SERVER to serve up your HTML page. I'm guessing that you can't just try to open a *file* in the browser.

I'm not sure what kind of local web server you can install on a Mac. Maybe need to ask in a Mac forum.

However... One thing that *might* work is to clearly use the "file://" protocol in the address line.

For example, if currently the address bar of the browser shows "somePath/someFile.html", change it to "file://somePath/someFile.html".

(With MSIE, if you have any JS code in an HTML file and you omit the file:// protocol, and just use "c:\whatever\file.html", MSIE will warn you about unsafe scripting. It's kind of the same thing.)

Anyway, your HTML is clearly valid.
Reply With Quote
  #5 (permalink)  
Old September 10th, 2010, 02:47 PM
Registered User
 
Join Date: Sep 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks - I'm betting on the web server, but I'll try both
Reply With Quote
  #6 (permalink)  
Old September 10th, 2010, 06:42 PM
Authorized User
Points: 105, Level: 2
Points: 105, Level: 2 Points: 105, Level: 2 Points: 105, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi,

You should be able to create or edit HTML files in TextEdit on the Mac without needing a server. First thing to check out is that your file extension is being saved as a .html file extension (not .txt):

http://webdesign.about.com/od/textedit/a/aa122006.htm

Second thing you may find is that when you go to open the HTML page in TextEdit again, TextEdit might also try to display the page as it would in the browser (rather than showing you the code). You can get around that by following the instructions on the second part of the page:

http://www.askdavetaylor.com/how_do_..._mac_os_x.html

(One other thing to watch out for: make sure you have TextEdit in plain text (not rich text format too.)

Hope that helps!
Reply With Quote
The Following User Says Thank You to bitnap For This Useful Post:
  #7 (permalink)  
Old September 10th, 2010, 07:47 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

bitnap: The file *looks* fine. So I think he has edited it successfully. He just can't display it successfully. He has exactly the *opposite* problem from what you described in your "Second thing..." paragraph. It always shows the raw text--the code markup--doesn't show as a web page.

Anyway, what does/should the text editor have to do with " when I opened it in Safari 5 it showed me all my code..."?? He says he *IS* opening it in Safari.
Reply With Quote
  #8 (permalink)  
Old September 10th, 2010, 08:09 PM
Authorized User
Points: 105, Level: 2
Points: 105, Level: 2 Points: 105, Level: 2 Points: 105, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2010
Posts: 19
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hi Old Pedant - I completely agree that the code that shoes posted will look fine. However, it would appear to me that the mac is probably treating the code created in TextEdit it as a .txt file (not an HTML file - as explained in step 4 of the first link).

I have seen mac users save a file in TextEdit before, and they have tried to add the HTML extension, however TextEdit has added .txt onto the end (so it becomes filename.html.txt).

This is easily be done, especially when the mac is set to hide file extensions (and this is an issue I have come across before with newcomers to HTML).

So if Safari is trying to open what it thinks is a text file, then it will render it like a text file (rather than trying to process the code as an HTML file) and this would explain why Shoes is seeing the code in Safari.


The reason I posted the second link is that, if I am correct and Shoes saves the file with an .html file extension, *then* the second problem may occur (because text edit can try to render HTML files as the browser would show them rather than showing the code).

Anyway, hope that explains it a bit better. And Shoes, do let us know if you still have problems.
Reply With Quote
  #9 (permalink)  
Old September 10th, 2010, 08:19 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Ah, yes...makes sense. I've had similar problems with editors on windows. On windows, at least, the solution is to put "..." around the file name in the "Save as..." box and then the default extension won't be tacked on. And, yes, I *HATE* having my file extensions hidden. First thing I do when I install a new version of windows is go turn of that "feature". [Remember, "a feature is a bug that has been documented." Hmm...I wonder if that means all of windows is a "feature"?]
Reply With Quote
  #10 (permalink)  
Old September 13th, 2010, 12:08 PM
Registered User
 
Join Date: Sep 2010
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Finally! I'm afraid as a newbie to both Mac and HTML I wasn't quite clear on the extensions, now that I have THAT figured out, it worked. Thanks much
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need some help on basics jagan7 Java Basics 3 September 9th, 2007 02:44 AM
Basics Andy122 Dreamweaver (all versions) 3 January 2nd, 2005 02:36 PM
PHP basics limsra BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 August 18th, 2004 07:28 AM



All times are GMT -4. The time now is 11:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.