I am looking for support editing stylesheet of my website
I have the below in the file main.css
.bg-danger, .bg-success {
padding: 0 5px;
}
a {
color: #EF1F2F;
text-decoration: none;
}
Then there is a header file header.php with the following code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?=isset($title) ? $title : null;?></title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="style/main.css">
</head>
<body>
My requirement is to change the background, font etc.
I am not familiar with working on stylesheets. Requesting support from other members.. Thanks in advance
Into your main.css file you can start with adding some minimum properties like :
body {
background-color: #yourHexCodeColor;
font-family: "Helvetica", sans-serif;
}
Then learn the very basics of css right here => https://learn.shayhowe.com/html-css/getting-to-know-css/
Unfortunately, you can't edit CSS code coming from an external source.
So what you have to do is to overwrite the styles you need to be changed in another stylesheet. In your case, it would be the main.css file.
So if there is a style in the bootstrap file that looks like this:
body {
background-color: #fff;
}
You can make a copy of that style in your own file (main.css) and change the value. So in your file, you have this:
body {
background-color: #f7f7fe;
}
Related
I was trying to upgrade a website that I made on Atom with css but my code isnt working. When I was trying to use the style tag, my code seemed to work as expected but as soon as I tried to use a link tag instead it went back to how it was before. I really want to fix the issue. Here is the code on my main page:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>☆My Test Site☆</title>
<link rel="stylesheet" href="css/styles.css">
</head>
Here is the code for a different file called styles.css:
body {
background-color: #FFE6E6;
}
hr {
border-style: none;
border-top-style: dotted;
border-color: grey;
border-width: 5px;
width: 5%;
}
Btw I have been double checking for over a day now so i dont think there is a problem with the file name.
I solved the problem. It turns out that my css folder wasnt on the same level as my other folder which had my main file in it!
I am trying the code in the link shown below for responsive layout design.
1) As it it, if the CSS code is included in the html code displays perfectly as expected
2) But if I move the exact CSS code as a different file and link to it from the html code, visually the boxes layout don't work so well. The result seems similar in different browsers.
Would someone know the reason for that? I was expecting to get more similar visual results
Also would it be good in general for a website html code to include the css in the html code as in (1) or as a different file as in (2)
https://www.w3schools.com/css/tryit.asp?filename=trycss_website_layout_blog
Here is the code I used to link to css file
<!DOCTYPE html>
<html lang="en-US">
<body>
<head>
<title>My page</title>
<link rel="stylesheet" href="styles.css">
</head>
here is the top code of the CSS sheet
<title>CSS Template</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
And here is a screenshot of the result
edit
reviewed css sheet code after Lunex answer (top part)
* {
box-sizing: border-box;
}
body {
font-family: Arial;
padding: 10px;
background: #f1f1f1;
}
Create a css file. Let's say you name it "style.css".
In this file you put all the content which is in the < style > tag.
In your html file inside the head tag you add:
<link rel="stylesheet" href="style.css">
This should be working, considering you've done everything right.
Edit for your edit:
You don't need html tags in your css file.
The content of the html file should be:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<!-- the body content here -->
</body>
</html>
The content of your css file should be:
* {
box-sizing: border-box;
}
body {
font-family: Arial;
padding: 10px;
background: #f1f1f1;
}
// ...
#media screen and (max-width: 400px) {
.topnav a {
float: none;
width: 100%;
}
}
I just approached HTML and CSS.
I wrote a little HTML5 file and a CSS file, but my HTML doesn't get any info from CSS because nothing is styled.
I'm using Eclipse, there is a directory "WebContent" where there is the HTML file, and the CSS is in WebContent/WEB_INF/CSS/file.css.
HTML file:
<html lang="it">
<head>
<link rel="stylesheet" href="/WEB-INF/CSS/NewFile.css" type="text/css">
<title>Strumenti musicali</title>
<meta charset="UTF-8">
<meta name="description" content="Negozio di strumenti musicali">
<meta name="keywords" content="strumenti, musicali, negozio">
<meta name="author" content="Paolo">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<nav>
HTML |
CSS |
JavaScript |
jQuery
</nav>
<h2>The title attribute</h2>
<p title="I'm a tooltip">
Mouse over this paragraph, to display the title attribute as a tooltip.
</p>
</body>
</html>
and the CSS file:
head {
display: none;
}
body {
background-color: lightblue;
display: block;
margin: 8px;
}
body:focus {
outline: none;
}
h1 {
color: white;
text-align: center;
}
nav {
display: block;
}
p {
font-family: verdana;
font-size: 20px;
}
I don't know how the CSS file has to be indicated, because the file .html is in the directory "WebContent"; The CSS file in WebContent/WEB-INF/CSS/NewFile.css; The path I used is "/WEB-INF/CSS/NewFile.css" and still doesn't work.
EDIT:
It seems to work on Chrome and Edge, but neither in Firefox, nor in Eclipse.
Try to use the path "/WEB-INF/CSS/NewFile.css", that's to say a relative path from the html file to the css one.
The path to your CSS file is incorrect. Assure that the relative path and filename match that of your intended CSS file.
In your case the path specified in html file points to "NewFile.css" which does not match "file.css", as Blackbam has mentioned. Other issues exist in the directory names as well. Fixing this will fix your issue.
I would also add that StackOverflow is not intended as a website to debug your issues.
I'm a real noob at CSS/HTML, so please forgive me.
I tried to change the background page color on the CSS file linked to my html file, and it doesn't work. Whereas when I just flat out change it between the style tags in my HTML file, it works. What gives?
Plain and simple:
Ex1.css
<head>
<style>
body {
background-color: lightblue;
}
</style>
</head>
SamplePage.html
<!doctype html>
<html>
<head>
<title> Sample Page </title>
<link rel = "stylesheet" href="Ex1.css">
</head>
<body>
Hello. This is a sample Page.
</body>
</html>
Your HTML is correct, and links to your CSS correctly (assuming Ex1.css is in the same folder as your HTML).
Your CSS is almost correct; the only problem is that you shouldn't include any HTML tags in your CSS document. Ex1.css should only contain the actual CSS declarations themselves (body { }).
body {
background-color: lightblue;
}
<body>
Hello. This is a sample Page.
</body>
If in doubt, you can validate your CSS with W3's CSS Validator.
Hope this helps! :)
Reduce the contents of your Ex1.css file to this:
body {
background-color: lightblue;
}
(no HTML code in CSS files!)
your css file will just have. Plain and simple
body {
background-color: lightblue;
}
change your css file to this:
body {
background-color: lightblue;
}
I really hope you can help me because I spent 2 days now looking for my mistake. I want to link an external css stylesheet into my html website but the website opens without css affecting it. I already validated both codes and checked spelling 1000 times, still not working. I tried with FF Chrome and IE:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset = "UTF-8"/>
<link rel="icon" type="image/png" href="bilder/favicon.png" />
<title>Die Hauskatze</title>
<link rel="stylesheet" href="css/stylesheet.css" type="text/css" />
</head>
Stylesheet:
#charset "UTF-8";
body{
background: url(bilder/background.jpg);
}
img {
border: 4px black;
}
your css file is probably is in another folder than your bilder folder. Be sure to specify this in the path.
If the css file is in a css folder for example, you need to go one folder up then in you bilder folder.
body{
background: url("../bilder/background.jpg");
}
for the border you need to specify the border 'style' (solid, dotted, etc)
border: 4px solid black;
https://www.w3schools.com/cssref/pr_border-style.asp
For starter you can try to add quotes to your URL here
body{
background: url(bilder/background.jpg);
}
change it to:
body{
background: url("bilder/background.jpg");
}
If that doesn't help it is quite likely that your path is wrong.
You can see it inside your developer console once the page is being loaded.
In case of wrong url you will get an error that the img file was not found.