Home

How to Link Cascading Style Sheets (CSS) with Dreamweaver

|
|  Updated:  
2016-03-26 14:58:48
HTML & CSS Essentials For Dummies
Explore Book
Buy On Amazon

Dreamweaver users can easily insert a link tag to an external Cascading Style Sheet (CSS) without having to commit to memory all the required code or the proper syntax. Moreover, when creating links to an external CSS file in Dreamweaver, you can also use that opportunity to select a CSS media type, if desired.

In the following steps, you find out how to link an external CSS file with the all media type to an open HTML file in Dreamweaver.

To complete all the steps, you need Dreamweaver along with sample HTML and CSS files, which you can quickly create on your own.

Place both copies of the saved files into a folder on your computer and then proceed with the following steps:

  1. Launch Dreamweaver and set up a managed site by choosing Site→New Site.

    The Site Setup dialog box appears, showing the Site category, which displays fields for the Site Name and Local Site Folder.

  2. In the Site Name field, enter the name of your site.

    Enter a name that matches the name of the client or indicates your site’s purpose is best, such as ABC Company or My Blog.

  3. In the Local Site Folder field, verify that the path points to the folder on your computer that you want to use for this site.

    For example, if you have a folder on your computer dedicated to local websites and you want to create a folder inside that to house the files for a new ABC Company website, your Local Site Folder path might be something like this:

    UsersyourusernameDocumentslocal-sitesABC web
  4. Click Save to close the dialog box.

    Your new managed site opens, displaying all the existing files and folders (if any) in the root folder in the Files panel.

  5. From the Files panel, open the HTML file that you will be adding the CSS link to.

    The file you use should have some type inside of it and be marked up with paragraph, h1, and list tags.

  6. To add the link, click the Attach Style Sheet icon (which looks like a little piece of chain) at the bottom of the CSS Styles panel.

    Clicking the icon opens the Attach External Style Sheet dialog box. If you don’t see the CSS Styles panel in the Dreamweaver workspace, choose Window→CSS Styles to open it.

    image0.jpg
  7. In the File/URL text field, type the name of the CSS file you’d like to link to or click the Browse button to find and select the desired CSS file.

    If you’re using the sample files you just downloaded from the web, click the Browse button to navigate to the location where you saved the sample files and select the file cssdemo.css.

  8. In the Add As area of the dialog box, click the Link or Import radio button to select the desired method for adding the CSS file to your HTML page.

    The Link option adds the CSS as an external file by using the tag:

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

    The Import option specifies the external CSS within a style link inside the head of the page by using the @import at-rule. Keep in mind that this method is not recommended for CSS3 media queries:

    <head>
    <style type="text/css">
    <!--
    @import url("cssdemo.css");
    →
    </style>
    </head>
  9. In the Media drop-down menu area, type the word all, or click the menu’s down arrow and select the all media type.

    To specify multiple media types rather than just one, enter the names of each of the desired media types, separated by commas and no spaces, as in screen,print,tty.

  10. If desired, click the dialog box’s Preview button to see how the newly linked CSS file styles your sample HTML file.

  11. Click OK to complete the attachment of the external CSS file.

    Dreamweaver’s CSS Styles panel now displays the newly attached CSS file and lists all the styles inside it, and the sample HTML file is styled with the style rules on the linked CSS.

About This Article

This article is from the book: 

About the book author:

Sue Jenkins is a working designer as well as a design trainer and author. Her design firm, Luckychair, provides design services for web, logo, and print. Jenkins has also created a series of courses on popular Adobe design tools including Photoshop and Illustrator.