How do you merge css and html? please explain | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do you merge css and html? please explain

21st Jun 2016, 4:24 PM
Manav Shah
Manav Shah - avatar
2 Answers
+ 4
There are three ways of inserting a style sheet into an HTML document: 1. External style sheet With an external style sheet, you can change the look of an entire website by changing just one file! Each page must include a reference to the external style sheet file inside the <link> element. The <link> element goes inside the <head> section: <head> <link rel="stylesheet" type="text/css" href="style.css"> </head>. An external style sheet can be written in any text editor. The file should not contain any html tags. The style sheet file must be saved with a .css extension. body { background-color: lightblue; } h1 { color: navy; margin-left: 20px; }. 2. Internal style: An internal style sheet may be used if one single page has a unique style. Internal styles are defined within the <style> element, inside the <head> section of an HTML page: <head> <style> body { background-color: linen; } h1 { color: maroon; margin-left: 40px; } </style> </head> 3. Inline style: An inline style may be used to apply a unique style for a single element. To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property. <h1 style="color:blue;margin-left:30px;">This is a heading. </h1> The example below shows how to change the color and the left margin of a <h1> element:
16th Jul 2016, 6:24 PM
Awele Omeligwe
Awele Omeligwe - avatar
0
if you, for an example, trying to style all paragraphs using css, you need to insert the css code inside the html document. This is just an example, you can copy and paste it in your code play board! <html> <head> <title>styling the html codes </html> <style> p { background-color:yellow; font-family:Georgia; } </style> </head> <body> <p>I'm yellow and my fonts are Georgia</p> <p>I'm also what he said </p> <p>Me too </p> <p>Me three!</p> </body> </html> Notice anything unusual? yes, it's because I inserted the "Style" code. it's from css and with it, you can style anything, the body, the article, the footer, anything!
1st Jul 2016, 5:30 AM
Sinethemba Gomba
Sinethemba Gomba - avatar