Professional Documents
Culture Documents
Computer Science PDF
Computer Science PDF
Computer Science PDF
2
- **Definition**: External CSS involves linking to an external CSS file
using the `<link>` tag within the `<head>` section of the HTML
document.
- **Example**:
```html
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<p>This is a paragraph.</p>
</body>
```
With `styles.css` containing:
```css
p{
color: blue;
font-size: 14px;
}
```
- **Advantages**:
- Allows for separation of content and presentation.
- CSS can be reused across multiple HTML documents, promoting
consistency and easier maintenance.
- Reduces page load time once the CSS file is cached by the browser.
- **Disadvantages**:
3
- Requires an additional HTTP request to fetch the CSS file, which can
slightly impact initial page load time.
- Changes in the CSS file will affect all linked documents, which may
require careful testing.
Using CSS effectively often involves combining these types based on the
needs of the project. For instance, external CSS is commonly used for
general styling, internal CSS might be used for page-specific overrides, and
inline CSS could be applied for unique or one-off styles.