Home Web Front-end CSS Tutorial Some skills you need to pay attention to and master when coding CSS in DW_Experience exchange

Some skills you need to pay attention to and master when coding CSS in DW_Experience exchange

May 16, 2016 pm 12:04 PM
css dw

Due to the "visualization" and easy operation, many friends write CSS in DW. Today we introduce some "best habits" for writing CSS in DW, hoping to be helpful to everyone.
CSS is changing the process of website design. To cater to the growing number of CSS-inclined designers, Macromedia DW MX introduces a number of new and improved CSS-related features. With these new features, you can plan for future updates and develop sites that are more compliant with W3C standards. This article discusses some suggestions for using CSS in DW MX and highlighting a specific CSS feature.
Generally speaking, a style sheet is a collection of formatting rules that control the appearance of web content. CSS can be used in your pages in three different ways:

Copy code The code is as follows:

Inline: a one-time style written into the code.
Embedded: A style sheet that can control all elements in a page
External: A style sheet that can control elements in many pages
In fact, many sites are based on These three methods need to be used in combination.

An important fact to consider when working with CSS is that different browsers and different versions of the same browser parse CSS in different ways. In addition to the differences in web browsers, you also need to realize that there are many other browsers, such as hearing browsers, TV-based browsers, and handheld devices such as the Palm Pilot and TTY (teletypewriter, remote typewriter).
What are best practices?
Most technologies have their own agreed-upon standards. CSS is no exception. While not all CSS that exists on the web is standardized, it is helpful to use CSS according to existing standards. In general, developers should separate content from reporting as much as possible. The benefits of this are:
1. Increase the lifespan of the site
Non-standard style sheets may be convenient at the time, but after the new version of the browser comes out, compatibility issues are likely to occur. At that time, modifying the site page by page will be a very time-consuming task and it will also make the use of CSS meaningless.
2. Make your site accessible to all users and browsers
Some local governments have legislated that websites must be accessible to people with disabilities. Browsing devices designed for disability awareness, such as hearing browsers, have extremely strict CSS normative requirements.
3. Make site updates and maintenance easier
When used properly, CSS can allow adjustments you make in one page to be quickly applied to all pages.
Your first choice is which style sheet to use. When it comes to best practices, here’s a breakdown of the different style sheets:
Inline CSS: Simply put, you should try to avoid using it. Among other disadvantages, using inline CSS means that you don't take advantage of the real advantage of CSS, which is that you don't separate content from formatting. DW MX uses Inline CSS mainly to position page elements (these elements are called "layers" in the DW MX user interface), or to use a certain DHTML effect, which requires using Inline style javascript to change an object. properties.
Embedded CSS: It is also not ideal because it can only affect the current page. During the update process, if a page is lost, the style of the site will be inconsistent; in addition, when users browse your site, style sheet information must be downloaded for each page.
External CSS: This is your first choice. External CSS allows all pages connected to it to maintain a consistent appearance and style; outline it, change it once, and easily update all related pages; make your page smaller and browse faster. Other best practices are discussed below when analyzing specific CSS features.
Create a CSS style sheet in DW MX
When creating a CSS style sheet in DW MX (Text 》CSS Style 》New style sheet), in the pop-up dialog box, you have two options: New style sheet Document (New Style Sheet File) and only for the current page (This Document Only). Select “New Style Sheet File” and you begin the process of creating External CSS.This option requires you to name the style sheet and select a save location for it before the actual creation process; the other option, This Document Only, will write the relevant code directly to the page.
You can also select an existing style sheet to edit or add new definitions in the "New style" dialog box.
Should it be linked to External CSS or imported?
After creating an external style sheet, you need to attach it to each page (or template). To do this, click the "Attach Style Sheet" button on the CSS panel. The Link External Style Sheet dialog box will pop up, where you can browse to your target style sheet. After finding the name, you can choose to link or import this external style sheet.
Linking is the most commonly used method. Select "link" to connect the style sheet to the page. It will add the following markup to your page:
All browsers that support CSS support the connection option. If you want some older browsers (such as Netscape 4.x) to "see" this style sheet, you need to use the following method.
If you select the "Import" option, the tags used are:
NetSscape4 will completely ignore the imported CSS and interpret the page according to the connected CSS. In this way, we can use the new features in CSS without worrying about browser compatibility issues.
CSS Property Inspector
You can easily switch to CSS mode in the property inspector of DW MX. By default, the Property Inspector displays font tags in raw HTML mode. Click the little "A" next to the Fonts drop-down menu and you'll see the currently available CSS stylesheets instead of a list of font tags.
At the same time, you can also easily switch back to HTML mode.
Ready-made CSS style sheets
One of the exciting CSS features in DW MX is that it includes ready-made CSS style sheets. New users of CSS can try it out first. Select File > New, select CSS style sheets in the pop-up new document dialog box, and a list of all available CSS will appear in the box on the right. To practice what we call best practices, choose one marked “Accessible.”
Save the document in the site folder, and then use the above method to attach CSS to your document.
Design Time style sheets
This feature of DW MX allows you to apply style sheets to pages while working in design view, giving you a more intuitive understanding of the appearance of your site. . Design time stylesheets will not appear within the site. This feature is very useful from the perspective of our best practices. If you use both import and link methods (as described above), attaching design-time stylesheets allows you to develop the site using either one. You can easily change to another style sheet when you want to see how the page will look under another style sheet.
Design-time stylesheets are also useful for developers who want to apply CSS to the server (such as ASP, PHP, or ColdFusion) or to access it on the client through JavaScript. Server-side style sheets are also another way to deal with poor CSS support in client browsers. But in previous versions of DW, this method did not allow you to view the actual effect of CSS during the design stage. Design-time stylesheets let you view stylesheet effects in real time, so you can work visually in DW MX. Another benefit is that when you upload site files, you no longer have to go through the entire site looking for redundant stylesheets.
Validation
Whether you create your own style sheet or edit an existing style sheet, validation ensures that you don't misuse nonstandard tags or incorrect code. DW MX itself does not include a CSS validator, you can use the validation service provided by the W3C site. Within DW MX you can validate HTML or DHTML tags (File > Check Page > Validate Markup (for HTML) or File > Check Page > Validate as XML for XHTML.). DW MX provides many auxiliary tools when developing CSS-based sites. With the help of MW MX, coupled with a good understanding of CSS, you can develop a site that will stand the test of time.
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use bootstrap in vue How to use bootstrap in vue Apr 07, 2025 pm 11:33 PM

Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

How to write split lines on bootstrap How to write split lines on bootstrap Apr 07, 2025 pm 03:12 PM

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

Understanding HTML, CSS, and JavaScript: A Beginner's Guide Understanding HTML, CSS, and JavaScript: A Beginner's Guide Apr 12, 2025 am 12:02 AM

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

How to resize bootstrap How to resize bootstrap Apr 07, 2025 pm 03:18 PM

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-

How to use bootstrap button How to use bootstrap button Apr 07, 2025 pm 03:09 PM

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

How to set up the framework for bootstrap How to set up the framework for bootstrap Apr 07, 2025 pm 03:27 PM

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to insert pictures on bootstrap How to insert pictures on bootstrap Apr 07, 2025 pm 03:30 PM

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

See all articles