Question

In: Computer Science

Using examples, explain the three (3) main ways to applying styles to an HTML document.

Using examples, explain the three (3) main ways to applying styles to an HTML document.

Solutions

Expert Solution

Explain the three (3) main ways to applying styles to an HTML document.

There are three ways to apply CSS to HTML: Inline, internal, and external.

Inline

Inline styles are plonked straight into the HTML tags using the style attribute.

They look something like this:


<p style="color: red">text</p>

This will make that specific paragraph red.

Internal

Embedded, or internal, styles are used for the whole page. Inside the head element, the style tags surround all of the styles for the page.


<!DOCTYPE html>
<html>
<head>
<title>CSS Example</title>
<style>

    p {
        color: red;
    }

    a {
        color: blue;
    }

</style>
...

This will make all of the paragraphs in the page red and all of the links blue.

Although preferable to soiling our HTML with inline presentation, it is similarly usually preferable to keep the HTML and the CSS files separate, and so we are left with our savior

External

External styles are used for the whole, multiple-page website. There is a separate CSS file, which will simply look something like:


p {
    color: red;
}

a {
    color: blue;
}

If this file is saved as “style.css” in the same directory as your HTML page then it can be linked to in the HTML like this:


<!DOCTYPE html>
<html>
<head>
    <title>CSS Example</title>
    <link rel="stylesheet" href="style.css">
...

Related Solutions

What are the three main parts of an HTML5 document?
What are the three main parts of an HTML5 document?
Using relevant examples, explain the five leader styles described the Normative Model of Leadership as they...
Using relevant examples, explain the five leader styles described the Normative Model of Leadership as they relate to participation during the decision-making process.
Explain Three (3) main characteristics of a monopoly.
Explain Three (3) main characteristics of a monopoly.
(a) Explain THREE (3) main characteristics of a perfectly competitive firm. [6 marks] (b) Using an...
(a) Explain THREE (3) main characteristics of a perfectly competitive firm. [6 marks] (b) Using an appropriate diagram, demonstrate how a perfectly competitive firm achieves equilibrium in the short-run. [7 marks] (c) Why is the demand curve of a perfectly competitive firm horizontal? Explain your answer. [7 marks]
Explain with examples three major ways major ways through which the development experience is a paradox
Explain with examples three major ways major ways through which the development experience is a paradox
Use the Guiding Principles document provided in the main menu. Select 3 guiding principles and explain...
Use the Guiding Principles document provided in the main menu. Select 3 guiding principles and explain how they can be applied to the digestive system. For each of them, provide specific examples of structures or physiological processes that exemplify the principle. Please provide 3 detailed paragraphs, one for each. Thanks Guiding Principles of A&P • Cells form the foundation of body structure and function • The body is organized into a hierarchy of increasing complexity • Body systems are functionally...
giving relevant agricultural examples, what are the three main ways that microorganisms affect our food supply?
giving relevant agricultural examples, what are the three main ways that microorganisms affect our food supply?
explain three advantages and three disadvantages of using composite materials with examples.
explain three advantages and three disadvantages of using composite materials with examples.
Describe two of the three attachment styles that were found using the Strange Situation Test. Explain...
Describe two of the three attachment styles that were found using the Strange Situation Test. Explain what each style represents the history of the relationship between children and mother.
Explain the main components of Globalization and the cultural flows that it produces, using appropriate examples.
Explain the main components of Globalization and the cultural flows that it produces, using appropriate examples.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT