Click to See Complete Forum and Search --> : [RESOLVED] What is purpose of type="text/css"


bkelly
08-05-2007, 08:55 PM
My CSS book says to include this link in pages that use a CSS file:

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

The book explains the rel= and the href, but does not explain the type well. I think the book is telling me that the server will send text to my browser telling the browswer how to render the page. The book also says there are no other acceptable values.

Do I understand this correctly? If there are no other acceptable values, then what advantage is there in including this phrase? Any disadvantages in leaving it out? I have not noticed any.

bkelly

kasey
08-05-2007, 09:23 PM
the type attribute is used to tell the browser what type of script it is looking at.

what the book means is that for linking to a .css file there is no other accetable values. there is different acceptable value's for the type attribute such as text/javascript , text/vbscript .

most browsers will still read the script without a type attribute but it's not valid html (page will have errors when you validate it)and may cause problems

ray326
08-05-2007, 11:11 PM
It means there are no other acceptable values for a stylesheet. All content (separate files) delivered by a web server have a content type, sometimes called a MIME type. A few examples,

GIF image: image/gif
HTML page: text/html
Stylesheet: text/css
Excel workbook: application/vnd.ms-excel
PDF document: application/pdf
ZIP file: application/zip
TXT file: text/plain

The nitty-gritty can be found at http://www.iana.org/assignments/media-types/index.html.

bkelly
08-06-2007, 12:52 PM
Well that was a relatively simple one. Thanks for your answers.
bkelly