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 6075665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:31:11+00:00 2026-05-23T10:31:11+00:00

I made an html wich links to a CSS file, open it in browsers,

  • 0

I made an html wich links to a CSS file, open it in browsers, and the styles show correctly.
Then I load it in a WebView and the styles don’t show.
I even tried to insert a <link> into the DOM from Objective-C, which is my ultimate goal, but neither worked.
Do I have to enable CSS on the webView somehow?

edit:
the CSS include in the html:
<link rel='StyleSheet' href="file://localhost/Users/petruza/Source/Scrape/build/Debug/Scrape.app/Contents/Resources/Scrape.css" type="text/css" >

the CSS inserted in the DOM: (I checked and it does get inserted)

NSURL *cssUrl = [[NSBundle mainBundle] URLForResource:@"Scrape.css" withExtension: nil];

DOMDocument* dom = [[web mainFrame] DOMDocument];

[window setTitleWithRepresentedFilename: lastRunScript];

DOMElement* link = [dom createElement:@"link"];

[link setAttribute:@"rel" value:@"StyleSheet"];
[link setAttribute:@"type" value:@"text/css"];
[link setAttribute:@"href" value: [cssUrl absoluteString]];
    
DOMElement* head = (DOMElement*) [[dom getElementsByTagName:@"head"] item:0];
DOMElement* headFirstChild = head.firstElementChild;

if( headFirstChild )    
    [head insertBefore:link refChild:(DOMNode *)headFirstChild];    
else
    [head appendChild:(DOMNode *)link];

edit2:
Same exact html shown in my WebView and in Safari:
enter image description here

  • 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-05-23T10:31:11+00:00Added an answer on May 23, 2026 at 10:31 am

    You might need to include an html <base> element to tell the webview where it shoul be looking for the css files.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made an html file called test.html then I navigated to it as http://site.com/test.html?test1=a
I've so far made a html and css file which have three images; title,
I have never made a blog before. I am proficient with html and css.
So i have this dropdown made in html/css/js.. it slides down on mouseover, but
I have a website made with html, css and images. My friends are seeing
I already have a page template made with HTML and CSS, and in it
So I made myself a little html/css template. And now I'm trying to actually
So I have made a web page of HTML, Inline CSS and JS. Since
Here is a simple Tell a Friend form I made in HTML, it's correctly
I made a web page with HTML and PHP and design it with CSS.

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.