0

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,

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

yeah I haven't confirmed via any docs that I have to write the html perfectly. But it's not that difficult to make my application write it correctly. So when in doubt... thanks for your input
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.