Outsourcing A Style Section To An External Css File

free web hosting
Free Web Hosting > Computers & Tech > Designing > Web Design and HTML

Outsourcing A Style Section To An External Css File

dserban
Not being an HTML designer, but having a requirement to make a web page look pretty, I now have the following problem (I am absolutely convinced the solution for this must be very, very simple, I just need to find the right tutorial, which I couldn't find even after googling with the keywords outsource style section external CSS file):

I want to take an inline <style> ... stuff ... </style> section from a web page, create a CSS file out of it, then replace the inline style section with a reference to the CSS file.

Take as an example the page you are reading now. How would I be able to accomplish that?

I know it's a basic question and I'll keep researching the Internet as we speak, but if anyone has a quick solution to this, it's your chance to earn some hosting credits.

Reply

faulty.lee
All you need to search is "external css", all the answer will pop right out

I just briefly show you how to do it

Create a plain text file with the css you wanted in it,
then add this line to the HEAD section
CODE
<link href="path/to/your/css" rel="stylesheet" type="text/css">

Example content of css file
CODE
.header {
    background-image: url(../images/header-bg.png);
    background-repeat: no-repeat;
    border-left: 1px solid #FFF;
    border-right: 1px solid #000;
    border-top: 1px solid #FFF;
    padding-left: 30px;
    padding-top: 8px;
    height: 35px;
}

basically it's what ever within the STYLE tag.

That's it.

Next time when you google, don't put the search terms as a question, it won't really work. All you need is just the keyword

Good Luck

 

 

 


Reply

dserban
Works as advertised, thanks faulty.lee

Reply

Mark420
Css is soo powerfull!! you could spend ages looking at all the things it can do, a lot of designers these days (me included) try to do virtually everything on the page using CSS.
Also having your CSS checked by a validator at http://www.w3.org/ is a must for serious designers.This will point out anything in the CSS that is not a "correct" way of using a CSS command.
You can also use this site http://www.cleancss.com/ to clean up and optimise your code.

Reply

pyost
QUOTE(faulty.lee @ Aug 11 2007, 10:50 AM) *
then add this line to the HEAD section
CODE
<link href="path/to/your/css" rel="stylesheet" type="text/css">


It is good practice to close these tags with " />" instead of just ">", because this is required in XHTML.

Another way to include an external stylesheet is to use the following code:

CODE
<style type="text/css" media="all">
    @import url(style_images/css_2.css);
</style>


While it works the same way as the previous one in newer browsers, it will not function in older ones (e.g. Netscape 4). If you don't see it as being useful, think of it this way - browsers that don't support @import also don't support CSS to the extent necessary today. In order to avoid any possible errors, you should use <link> for basic CSS rules (font-family, font-color etc.) and @import for advance ones, which wouldn't be recognized by older browsers anyway.

Reply

TavoxPeru
QUOTE(pyost @ Aug 11 2007, 06:32 AM) *
It is good practice to close these tags with " />" instead of just ">", because this is required in XHTML.

Another way to include an external stylesheet is to use the following code:

CODE
<style type="text/css" media="all">
    @import url(style_images/css_2.css);
</style>


While it works the same way as the previous one in newer browsers, it will not function in older ones (e.g. Netscape 4). If you don't see it as being useful, think of it this way - browsers that don't support @import also don't support CSS to the extent necessary today. In order to avoid any possible errors, you should use <link> for basic CSS rules (font-family, font-color etc.) and @import for advance ones, which wouldn't be recognized by older browsers anyway.

Thanks for the information, the use of @import was one of the few things that i don't completely understand about css until now.

Best regards,

Reply

faulty.lee
QUOTE(pyost @ Aug 11 2007, 07:32 PM) *
It is good practice to close these tags with " />" instead of just ">", because this is required in XHTML.

Another way to include an external stylesheet is to use the following code:

CODE
<style type="text/css" media="all">
    @import url(style_images/css_2.css);
</style>


While it works the same way as the previous one in newer browsers, it will not function in older ones (e.g. Netscape 4). If you don't see it as being useful, think of it this way - browsers that don't support @import also don't support CSS to the extent necessary today. In order to avoid any possible errors, you should use <link> for basic CSS rules (font-family, font-color etc.) and @import for advance ones, which wouldn't be recognized by older browsers anyway.


I didn't notice bout the "/>", i simply copied from one of my project file. Hmm, meaning most of my project are not XHTML compliant. Thanks for the info.

As for the @import, i seldom use advance CSS, and normally i target 1 specific browser only, mainly firefox, probably the same version, for simplicity. Thus everything should work as if it's photocopied. I don't deal with end user, i can ask my client to use what ever browser of my choice. One of the reason is security, and the other is shorter development time due to less issue with cross browser compatibility

Reply

pyost
I don't use @import, either, but it is a good thing to know. But let's face it - even without any precise data, I am quite sure 80 per cent of the Internet population uses newer browsers which deal with CSS rather well ("rather" is there because of IE smile.gif)

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Recent Queries:-
  1. external css on disk - 62.45 hr back. (1)
Similar Topics

Keywords : outsourcing, style, section, external, css, file

  1. Cbel.com >> 203 Manually Selected Sites About Style Sheets
    (0)
  2. Css File Size
    (7)
    Iam using a CSS file of 23+KB size, thats cuz i am not using tables XD, i am gona work on that and
    replace everything with tablesbut i still have alot of things to work on my sight. My question, will
    this cause any performance issues when people view my sight?....
  3. Style P And H? Html Tags
    (2)
    Well, I have found that css was very hard to predict and precise control their apperance. When mix
    and use the p and h? tags. Their apperaence were not identity. Place the h? tags within the p tag
    causes style error on both firefox and IE. So, anyone should do it reserved, instead, place the p
    tag with any h? tags will do the jobs on both browsers. Still learning it coz it much varies when
    doing styles. Tested it on XHTML 1.0 Strict....
  4. Cutenews 1.4.5 Security Alert Regarding Search.php
    please update your file immediately (1)
    Searching through our forum, I came across few posts mentioning "my site was hacked" while using
    CuteNews. So before I made this post I wanted to be sure if everyone here knew about CuteNew's
    serious vulnerability by searching our forum. I am also a victim of recent vandalism by someone from
    Germany who knew about this exploit. Please read Cutenews for clear understanding how, why and
    how-to. If you are using CuteNews as CMS for your site please visit the above URL and
    countermeasure for your CuteNews script. It looks like this information has been available sin....
  5. CSS Priority Problem
    I can't override an external rule with an embedded rule (7)
    First of all, to let you see my code, I've uploaded two example files: testpri.html and
    style.css . In my external CSS file, I applied a black background style to the li 's in #test
    . Then I added another style in the HTML file, turning the background color of the #hello list
    item into red. The result isn't what I expected. The #test list item became black, instead of
    the red style I applied to it in the HTML file. Don't embedded styles have a higher priority
    than external styles? And don't specific styles have higher priority too? #hello ....
  6. How To Use Psd File
    (14)
    I'm redesigning my website, and I found a template for it that is in a PSD format. I have Adobe
    Photoshop so I can open it and edit it. I changed the text and images exactly the way I want it, but
    what do I do from here? How do I get the images and text from the PSD to the individual files that
    makes it up? Or am I supposed to be doing that at all? Thanks....
  7. Get Input From Html/txt File?
    with just html/css and maybe javascript? (2)
    I was just wondering if it's possible to retrieve text (and maybe images) from a .html or .txt
    file. So for example you get the header and footer from an external file. Is it possible with just
    html/css and maybe a little javascript or does it require server side scripting like php???
    -=jeroen=-....
  8. Table Layout Vs. Css Layout
    So using tables is considered bad style? (18)
    I have heard that using tables for layout in a webpage is bad style. It is possible, but much more
    of a hassle, to get the same results using CSS (float), but is using float in this way really better
    style than tables? Most websitesstill use tables. Please give me your opinion, or the "general"
    opinion uif you think you know it, I'm curious, and can't decide which way yo go.....
  9. Css: Html Special Character As List Style?
    (2)
    I'm addicted to the character » (»). It just looks very neat and works well on lists...
    But my problem is, how can put HTML special character like » as CSS list-styles? If I just
    paste the character to the stylesheet in a text editor and use UTF-8 charset on my document, it
    won't print out. If I user the code » in the CSS file, it won't be shown as the
    character but the string "»". So is there any way to do this? I absolitely want to keep the
    UTF-char sets so changing that is not an option.....

    1. Looking for outsourcing, style, section, external, css, file






*SIMILAR VIDEOS*
Searching Video's for outsourcing, style, section, external, css, file
advertisement




Outsourcing A Style Section To An External Css File



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE