Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Connecting HTML and CSS | Introduction to CSS
CSS Fundamentals
course content

Contenido del Curso

CSS Fundamentals

CSS Fundamentals

1. Introduction to CSS
2. Text Styles
3. Box Model and Layout
4. Flexbox
5. Decorative Effects

book
Connecting HTML and CSS

Unveiling the Three Paths of CSS

The visual appearance of a webpage relies on the synergy between HTML and CSS. These technologies work in three distinct ways to style content: inline styles, embedded style sheets, and external style sheets. Let's explore each approach, highlighting their strengths and limitations.

Inline Styles

Inline styles allow applying CSS directly to an HTML element using the style attribute. This method is simple and useful for quick, dynamic changes. However, the drawback is their limited scope; they can't be easily extended or reused across different elements.

html

index.html

copy

In this example, the color: blueviolet style is applied directly to the <p> element, making the text appear in blueviolet. This style affects only this specific <p> tag.

Embedded Style Sheet

The embedded style sheet resides within an HTML document's <head>, encapsulated within <style> tags. This method allows us to tailor styles specifically to a single page. However, it lacks the versatility needed to be shared across multiple pages.

html

index.html

copy

Here, the <style> tag in the <head> section defines styles for all <p> elements. The text color is set to blueviolet, and the font size is increased to 36px. These styles are applied consistently across all document's <p> elements.

External Style Sheet

The external style sheet is the gold standard for CSS management in larger projects. It involves linking an external .css file to your HTML document using the <link> tag in the <head>. This method promotes scalability, maintainability, and reusability, making it ideal for multi-page projects.

html

index.html

css

index.css

copy

The external .css file contains reusable styles for the entire project. Here, all <p> elements in the HTML document are styled using the rules defined in the index.css file. The rel="stylesheet" attribute in the <link> tag specifies the relationship between the HTML and the CSS file.

Note

  • Inline Styles are suitable for single-element styling but lack reusability;
  • Embedded Style Sheet is great for styling a single page;
  • External Style Sheets excel in managing styles across multiple pages, streamlining your design process.
What ways of adding styles to the HTML document exist?

What ways of adding styles to the HTML document exist?

Selecciona unas respuestas correctas

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 2
We're sorry to hear that something went wrong. What happened?
some-alt