Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8387453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:12:55+00:00 2026-06-09T18:12:55+00:00

If I create inline styles they render, but when try to reference a css

  • 0

If I create inline styles they render, but when try to reference a css file in the same group and directory within xCode, they do not render.

Here is what I do:

<html>
<head>
    <link href="main.css" rel="stylesheet" type="text/css" /> 
</head>

<body>

    <h1>Hello, world! Learn</h1>

    <p>
    <a href="myscheme://advertising" class="buttonStyle">Click me!</a>
    </p> 
</body>
</html>

and then I have the css file called main.css like this:

body {background-color:#b0c4de;}
p {background-color:#e0ffff;}

Would anyone know why this would not render the css? Am I missing something important from the HTML header?

Here is how I call the HTML in the first place:

- (void)viewDidAppear:(BOOL)animated
{  
    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"learn" 
                                                         ofType:@"html"];

    NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
    [theWebView loadHTMLString:htmlString baseURL:nil];

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:htmlFile]];

    [theWebView loadRequest:request];
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T18:12:57+00:00Added an answer on June 9, 2026 at 6:12 pm

    The problem is in

    [theWebView loadHTMLString:htmlString baseURL:nil];
    

    Since baseURL is nil, the web view has no way to determine where your css file is. Instead of messing with manually creating data and loading it, pass the path of the HTML file directly to the UIWebView:

    NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"learn" ofType:@"html"];
    NSURL *url = [NSURL fileURLWithPath:htmlFile];
    NSURLRequest *rq = [NSURLRequest requestWithURL:url];
    [webView loadRequest:rq];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to create a jQuery Mobile dialog using inline content within the
I'm using tiny mce, but I found it adds multiple spans with inline styles
Related Topic: How to write a:hover in inline CSS? I need to create an
Possible Duplicate: Inline styles vs styles in CSS i guess i'm looking for some
Is it possible to create inline pseudo styles? For instance, can I do something
I'm trying to create a horizontally displayed list of services, however display: inline isn't
A few examples to show, just incase: Inline Table Valued CREATE FUNCTION MyNS.GetUnshippedOrders() RETURNS
Here's a live example I am attempting to create modules whose markup and CSS
I'm using CSS to absolutely position small elements from within paragraphs off to the
I'm trying to create a simple inline edit for a div box. When i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.