answersLogoWhite

0

When is external css used?

Updated: 8/9/2023
User Avatar

Wiki User

12y ago

Best Answer

It is sipmply a link to a stylesheet that is separate from the HTML document and contained in the Head element of the document. This references something I did:

<link href="crigbypubs.css" type="text/css" rel="stylesheet" media="screen"/>

<link href="print.css" type="text/css" rel="stylesheet" media="print"/>

done in XHTML

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

12y ago

external style sheets are .css files that are linked to your HTML file using @import or <link /> tags, as opposed to inline style sheets which are written inside of your HTML using a <style></style> tag or using the style attribute like <a style="color: red;" ></a>

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Mostly when it is used to format multiple pages. That is the beauty and utility of an external style sheet; the formating of multiple pages can be changed by a single stylesheet simply changing a single one

Another hint is to use two; one that contains basic formatting and a more targetted one specific to the page.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

There are two methods you can use to call an external stylesheet into an HTML document. The first is to use the link tag. The second is to use the CSS declaration, @import.

Using the LINK tag

The LINK tag contained in the HEAD section of the HTML document. It's used to describe the relationship between an external resource and the current document. LINK tags can only appear in the HEAD section, but you can have as many LINK tags as your heart desires.

Here it is, inside an HTML snippet.

Link Example Page

The link tag in the above snippet will tell the browser to go out and download the our_styles.css file, from the location we gave in the href attribute. That could also be a complete URL if you wanted. The rel attribute is used to define what kind of reference is being made (so the browser knows to treat our CSS file asCSS.) And the type attribute is just the file's MIME type.

There is also a "media" attribute, that would allow you to target a sytlesheet specifically for a particular media (like "print") if you wanted. It takes a comma separated list.

Strangely, none of the above attributes are required by the HTML specification for the link tag. But it's an empty tag, so without these attributes, it won't actually do anything.

LINK tags can be used to relate several other kinds of information to the document, so you might want to check out the related link to see them all.

Using @import

The @import declaration is a CSS declaration. As such, it can be contained inside a set of

As you can see, the @import declaration is pretty simple. You pass a url parameter after it (similar to using background-image declarations) The double quotes are required for valid XHTML, but aren't necessary for everything to work right. After you've passed the URL you can optionally pass a comma separated list of media types. These are the same media types as the LINK tag would take. Finally, the declaration ends with a semi-colon (like all CSS declarations.)

So which one should I use?

If you search the web, you'll find out that LINK has been supported since the beginning of time, whereas @import is newer. Some web developers will argue that you shouldn't use @import, because some browsers don't support it, or don't support it entirely.

However all major browsers since internet Explorer 6 have had full @import support. At this point, the folks still using those ancient browsers are used to a very broken internet.

@import is best used when you need to be able to programmatically add a stylesheet to override a prior stylesheet. This is because the STYLE tag can show up in the BODY without making the validator flip out. But due to some serious performance impact (see "don't use @import" in related links) I recommend always using LINK, unless you have a pressing reason otherwise.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

It is a sheet of code that is accessed with the <link /> attribute in HTML.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: When is external css used?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you make CSS layouts?

CSS layouts can be created in an external CSS file. The extension of the file should be CSS only.


How do you override css?

If you are using an External style sheet, CSS can be changed by embedding CSS code into the HEAD tag after the link to the external CSS file.Embedded CSS must be contained within a STYLE tag.EXAMPLE:


What are three aspects that can be controlled by CSS?

CSS can be integrated in three ways: Inline: Style attribute can be used to have CSS applied HTML elements. Embedded: The Head element can have a Style element within which the code can be placed. Linked/ Imported: CSS can be placed in an external file and linked via link element.


What are two way to change value of a css property?

There are not two but three ways to change. Inline, Internal and External CSS are three ways of changing CSS.


Type in css?

Typing in CSS is done inline, page or external. Inline is done right there in the HTML. Page is done in the Head element of the page. external is done by linking to a CSS file that is not included and is linked in the Head element of the document. Peace, carke


What is CSS in Dreamweaver?

CSS (Cascading Style Sheet) is an alternative way to style a web page. Using CSS makes the page load faster because the CSS code is in an external file not in the actual HTML document.


What is an embedded style?

Embedded CSS simply means that your CSS is written in an external file (i.e. not in your HTML file). The external file can be anywhere on your server and must end in ".css". You would call this CSS file from inside your HTML file like this:On the otherhand, inline CSS is when your CSS is included inside of your HTML code, for example:foo


What is CSS and how to apply CSS in HTML tag and attributes?

CSS is a rule based language - you define rules specifying groups of styles that should be applied to particular elements or groups of elements on your web page. CSS can be added to HTML documents in 3 ways : Inline - by using the style attribute inside HTML elements. Internal - by using a element in the section. External - by using a element to link to an external CSS file.


Difference between in-line and cascading style sheet?

Internal is normally called embedded CSS. It is place between the style tags which are place between the head tags on an HTML page. Inline CSS uses the style="" attribute and styles the tags directly. It will override any previous CSS styling.


How do you create link css to indexpage?

CSS can be made into a external page and linked to HTML. It can be done by the link tag like &lt;link src="abc.css"&gt;&lt;/link&gt;


Compare two methods of accessing external CSS script?

Let following be HTML page: &lt;HTML&gt; &lt;head&gt; &lt;link href='external_style.css' type='text/css' rel='stylesheet'&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Hello world&lt;/p&gt; &lt;/body&gt; &lt;/HTML&gt; and following be external css script: p {text-decoration:underline} Here is HTML document, in the head section tag &lt;link&gt; is used. Tag link is used to get reference of external style sheet page named "external_style.css" using href property. Both css page and HTML page resides in same directory. the external css page cannot contain any tags like:&lt;HTML&gt; or &lt;style&gt; it can contain only style specification like: p {font-size : 8pt} H1 {text-decoration:underline} etc


C why would you want to use the link tag instead of the style tag to define a style sheet?

&lt;link href="css/style.css" rel="stylesheet" type="text/css" /&gt; The link tag refers to an external stylesheet while the style tag is used if your CSS is inside the HTML document under the &lt;head&gt;.