I have a basic index.html file in a folder, as well as many, many other files. I want them all to use the same CSS file, without having to manually add to every file. I was wondering if you renamed the file index.css or something like that it would automatically load into every HTML file in the folder? Out of curiosity, is there also a Javascript method for this too?
Bad news my friend No. There is no magical tool that will import the CSS into all of your files. You have to do it yourself. Also it's really easy
Get the CSS file
Import the CSS File
See it's that easy. Was it so hard to do it?
You can't do that with simple HTML.
Do a PHP template instead, basically with:
head
header
nav menu
a content/container div/section
footer
Then, include your HTML/PHP page in your content.
For instance, use $_GET or $_POST to know which page to include.
Related
I am trying to practice some web development with a simple HTML file and some external styling. I have my HTML and CSS files saved in the same folder, and am attempting to link the CSS to my HTML file. When I go to view the page, none of the styling is applied. There is a file called "styles.css" loaded into the sources tab, but it just looks like my HTML file. The HTML included is from the file I want to link by the name of the file in the sources. You can see the link attempt (I've tried with and without specifying type, and I've tried putting a slash in front of the name of the file), and you can see the file included in sources:
I've looked at each element, I've looked at the computed styles, and nothing suggests that the file is properly loaded. I've looked through several questions and most of the solutions are things I've already tried. Thanks!
Make sure the index file is saved as a .html file.
If it's still not working try href="./styles.css"
try writing href="./style.css"
I want to make a simple little website, but I'm honestly not quite sure about how to structure the files.
To display a html-page under the link
samplesite.com/test
should I rather use:
main/test/index.html
Or:
main/test.html
Regardless the domain, the web browser will always look for the index.html of your project. So the domain.com/index.html is the way to go.
Answering the question based from the title. For html file structure, it is good to have the index.html on your root/project directory this:
Putting other web assets in different directory will help you to have a better file organization, you can also download some design/templating framework like zurb foundation and check the file structure.
The main page (opening page ) should be index.html coz when you upload it on apache /public_html folder by default it looks for index.html (or php in case you use php) so if your website is www.dummy.com ,by default when you go on it it serves index.html and to get test.html you have to use www.dummy.com/test.html
I would like to know if a plugin for SublimeText is available to optimise automatically my .css and .js (like http://cleancss.com/) when i save my file ?
Like that, in my html code I have just to link my .min.css instead of .css and it's always updated.
Thx
If you go to Package Control and search for minify you'll get a number of options. It looks like some of them are web-based, and some rely on local compilers. There are also a couple that only do JavaScript, and the rest do JS and CSS.
Good luck!
I know this may be a stupid question, im newer to this.
My menu bar takes over 1,000 lines in my html file. My client wants his index.html file organized so he can edit himself if needed.
I want to know if i can put my html for my menu in another files for instance in a file called : menu.html
and link in my index.html file by
<link href="../files/menu.html " type="text/html">
or in any other way that would work?
if you are using any programming language, use its code. For example, if you are using php
use
include_once('../files/menu.html');
How can I import an HTML file within my HTML file? I will prepare header.html and footer.html files separately and every file that I want to include them I want to import them into my HTML file.,
EDIT: I see that solution based on SSI technique. I use Ubuntu and Tomcat 7.0.11. How can I enable SSI at tomcat?
There are many solutions to this problem. You can write simple JavaScript code to include parts of your page on load, you can enable SSI on your web-server, and finally you can use any server-side language to dynamically include chunks of any page for output. Your choice depends on how dynamic your web-site is.
You can include html files using frames or iframes. If you're using a server side language such as PHP or ASP you can do this without frames using includes.
If you wanted to strictly use HTML (and assuming you are using JS too) I would do the following:
You could have a <div> for the header, I will call it <div id="header">.
Using jQuery we could say something like: $('#header').load(---html file---);. Aside from the pain it might be to include the JS file in all pages, it will allow you to make changes to the header globally throughout your application.