Open links in new tab
  1.  
  2. How to Link CSS to HTML – Stylesheet File Linking

    • Learn how to use the link tag with rel, type and href attributes to link an external CSS file to your HTML file. See examples and explanations of each attribute and why you should keep your CSS separate from yo… See more

    How to Link CSS to Html

    To link your CSS to your HTML, you have to use the link tag with some relevant attributes. The link tag is a self-closing tag you should put at the head section of your HTML. To li… See more

    FreeCodecamp
    Attributes of The Link Tag

    The rel Attribute
    rel is the relationship between the external file and the current file. For … See more

    FreeCodecamp
    Final Thoughts

    This article showed you how to properly link an external CSS file to HTML with the linktag and the necessary attributes. We also took a look at what each of the attributes … See more

    FreeCodecamp
    Filename extension.css
    Internet media typetext/css
    Developed byWorld Wide Web Consortium (W3C)
    Initial release17 December 1996
    Feedback
     
  1. 123

    To link an external CSS file to your HTML, use the <link> tag within the <head> section of your HTML document. This method keeps your CSS separate from your HTML, promoting better organization and maintainability1.

    Example

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="styles.css">
    <title>Link CSS to HTML</title>
    </head>
    <body>
    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
    </body>
    </html>

    Attributes of the <link> Tag

    • rel: Specifies the relationship between the current document and the linked resource. For CSS, use rel="stylesheet"1.

    • type: Specifies the type of the linked document. For CSS, use type="text/css"1.

    • href: Specifies the location of the CSS file. For example, href="styles.css" if the CSS file is in the same directory as the HTML file1.

    Internal and Inline CSS

    Was this helpful?

    See results from:

  2. How To Add CSS - W3Schools

    Learn three ways of inserting a style sheet: external, internal and inline. See examples, tips and exercises on how to use CSS to format HTML documents.

  3. CSS Styling Links - W3Schools

  4. HTML <link> Tag - W3Schools

  5. External CSS Stylesheets – How to Link CSS to HTML …

    Aug 24, 2021 · Learn how to use the link element and the rel, href, type and media attributes to import an external CSS stylesheet into your HTML file. See examples of different scenarios and media queries for responsive web design.

  6. <link>: The External Resource Link element - MDN Web Docs

  7. People also ask
  8. :link - CSS: Cascading Style Sheets | MDN - MDN Web Docs

  9. Styling links - Learn web development | MDN - MDN Web Docs

  10. How to add CSS to HTML (Link, Embed, Import & Inline …

    Feb 19, 2009 · Learn four ways to add CSS to HTML: link, embed, import, and inline. Compare the pros and cons of each method and see examples of how to use them.

  11. How to Link CSS to HTML Files: An All-You-Need-to …

    Feb 15, 2024 · Learn how to link an external CSS file to an HTML document using the tag and its attributes. Find out the benefits and drawbacks of using CSS and why it is important for web design.