Reputation: 422
I'm using UIWebView to display text via the method:
loadHTMLString:baseURL
The HTLMSting is created in the application on a different view and passed into another view via the above method. I'm wondering if there is a best practices for the HTML used in UIWebView. I've read through the class reference and done the usual search.
for example I can add:
<html>
<body>
<p> for a new paragraph </p>
</body>
</html>
or just have:
<p> for a new paragraph </p>
and it seems to function properly.
also just:
<p> for a new paragraph
seems to work fine, but based on what (little) I know about HTML most browsers can handle that (without the end tag) but can have unexpected results.
and I suppose technically I could just put in:
<br />
<br />
and it will work essentially like a new paragraph (and probably what I will do if there are no issues).
So my question is: for a shipping application how strictly should I "follow the rules" when writing the HTML specifically for displaying text in UIWebView? Is it the lettler of the law or can I just do what works?
Thanks for taking the time,
Upvotes: 0
Views: 620
Reputation: 342
UIWebView show HTML like as Safari do, you must "follow the rules" and use valid HTML tags. Safari can show HTML 5 same is for UIWebView control. It is very flexible but you must use valid HTML like to create web site to any other type of browser for PC or other devices.
Upvotes: 1
Reputation: 316
Personally, I always try to write valid HTML. If this UIWebview is the only view on the screen, then it should be well-formatted HTML. That means having the html, head, body, open and close paragraph tags.
You could use one of the html validators, too, after the fact to see if you've done everything right.
Upvotes: 2