The file should open in your default web browser, but with red paragraph text. Navigate to your GCF Programming Tutorials project and click inside.Once you’ve added the element inside the element, save your index.html file and you can view your changes in your browser. However, you could also use a full file path (C:\Users\You\styles.css) or a web address ( ) if you had your styles.css file stored elsewhere. Because your files are all in the same folder, you can just use the name of the file to point to it. href: like an element, the element also includes an href (hypertext reference) that points to the file you want to link.In this case, the relationship is “stylesheet” because the file you are linking is a CSS stylesheet. rel: the rel attribute specifies the relationship between the two files.Instead, it defines a connection between two separate files using two HTML attributes: Like the other elements that go in the element, the element will not actually appear on the page. Inside the element, add this new element:.There should be nothing in there except for a element right now. In Sublime Text, open your index.html file. Follow these steps to attach your CSS stylesheet to your HTML document: However, before it can actually do that, your HTML document needs to know about your new stylesheet.īefore your HTML and CSS can work together, the two files- index.html and styles.css-need to be connected to each other. We’ll talk about the color declaration more later on, but for now, all you need to know is that it’ll make your paragraph text red. This ruleset targets every element on the page. Type or copy the following into your empty stylesheet and save it: Now that you have your empty styles.css stylesheet open in your text editor, you can write your first CSS. You could call it anything you wanted, but styles.css is a common choice. Like the index.html file in your project, there isn’t anything fundamentally different about this file and a text file the file extension is the only real distinction.Īlso, just as index.html was a popular naming convention for the home page of a website, styles.css is a popular naming convention for the main stylesheet of a webpage. You have now created an empty CSS stylesheet. Name your file styles.css and press the Save button.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |