Stack1's Posts
Nairaland Forum › Stack1's Profile › Stack1's Posts
1 2 3 4 5 6 7 8 9 10 11 12 (of 12 pages)
Next in the HTML file (opened in notepad for editing) delete the style tag (both start and end tag), then add the following line inside the head tag/element
What we just pasted/typed is a link element and one of its uses is to link external CSS files to web-pages, the link element as shown is an empty tag and doesn't have a closing tag, also you'll notice it has three attributes 1. rel this simply shows the relationship of the kind of document we are linking to and thus its value stylesheet 2. the type attribute provides the mime-type used in recognizing the type of document, every document type has a unique mime-type, and its usually based on the extension of the file, in this case the extension is (.css), a very comprehensive list of mime-types is here http://www.iana.org/assignments/media-types/media-types.xhtml 3. The href attributeis the attribute that really concerns us the most the href attribute points to the actual file we want to linking to, its value in this case is "css/index.css" , this is because the css folder is a sub-folder of the main project folder where index.html resides, and since we are linking from index.html, we need to instruct the browser to first go into the css folder then link with the index.css file within that folder If everything up to this point is done correctly and you save the index.html file and refresh your browser, you should see the background of the body change colour, as that is the only CSS declaration we put into the external style sheet which is now linked to our web page |
We have seen basic CSS usage in previous examples where we had the the CSS style declarations in the STYLE tag, while this method works, it is not usually recommended combining HTML and CSS in the same file as it could lead to difficulty in maintain and managing your web-pages as time goes by (this is why we left the style tags empty in the last example From Now on we are going to utilize a facility called external style-sheets With external style-sheets we place our CSS style declarations in a separate file and then link that file to our html web-page. Now perform these steps Open up the recently created index.html file for editing open a new notepad and save as index.css, make sure this file is saved in the CSS sub-directory of the project folder structure we earlier created the index.css file we just created is our first external stylesheet so lets put some CSS into it, add the following to the index.css file
save the changes made to the CSS file. |
We have already looked at the basis of an HTML file so assuming you have created the index.html file open it in notepad and edit as follows [code] <!DOCTYPE html> <html> <head> <title>My Web App</title> <!-- our normal style tag where our CSS has been going --> <style> </style> </head> <body> <div id="header"> <span id="header-text"> Welcome to the Application </span> </div> </body> </html> Save and open i your browser, you should see a black line of text saying "Welcome to the Application", also notice that we do not have any CSS declaration within the style tag, we not using the style-tag in this example rather we would be using external style sheets. Also within the <body> tag/element, there contains only a DIV tag/element (remember DIV is a block element) which surrounds another SPAN tag and the SPAN tag contains the text that's displayed, when an element is contained within another its called a CHILD element so the SPAN is a child of the DIV element and the DIV is termed the parent Element. save and view the page in your browser |
hi all, so lets proceed Now whenever you're working on a web based application, you'll normally have your files/web-pages and other resources like images e.t.c. arranged using a directory structure suitable to the project, you don't just place/save your files in arbitrary locations on your hard-drive. Most web applications have the need for the user to move between pages and sections or access resources in other locations that are not even part of the project, HTML5 links are one way to provide access to other resources from a web-page. Lets assume we have the ff folder structure
So within the project directory we have a CSS folder for external style-sheets (to be explained soon), images, script (JavaScript files), and a server folder to contain other HTML files and also server scripts. Now in the root folder we have an index.html file which would be the start of our web-app Create a similar folder structure before proceeding |
in any case sha lemme put my own framework written from scratch by my self its called tigerjs, its a full-fledged library with many advanced modules like an Iterator modelu, an IO module, a utility module, widgets module(s) amd much more.. see it here https://sourceforge.net/projects/tigerjs/ hope u guyz wouldn't mind taking it for a spin, i have actually used it on an already released project and its the only library i needed. |
//carefully study the following code, would discuss it a bit later, its nothing complex just a lumped up example of what we have been looking at
Please make sure you type and run this code, and yeah i'm sure they'll be questions and some attacks for this ![]() |
Ok so what is happening here, we have an integer variable j that is initialized to zero, in the do while loop, the statement which prints the value of our integer variable is printed first (in the do section), then the variable is incremented. all this happens before the looping condition j <= 8is checked This loop continues to run (increasing the value of the integer variable j on each run till the test-condition fails, that's basically the story of the do-while loop |
The while and for loops as stated earlier are entry-controlled loops as their conditions for looping is checked once before each run, however there exists another similar looping construct do..while which runs at least once before its looping condition is checked and it is termed an exit-controlled loop [size=16pt]do while{}[/size] The do while{} loop executes its statement(s) once before checking its loop-condition, if the loop-condition then still holds true it executes again and again till the condition is no longer true Form of do-while loop –
|
// Program to find factorial of a number // For a positive integer n, factorial = 1*2*3...n Ok, not too get too mathematical (no be say me sef sabi math like dat), but this example calculates factorial, in summary lets say we have a number 5 the factorial would simply be 1*2*3*4*5, and if w have a number 55 the factorial would be 1*2*3*4*5*....55, ok they are other better ways to calculate factorials and we would still revisit more proper factorial programs later on
This example calculates the factorial of 8, the loop's control-condition simply checks to make sure the value of the number variable is greater than 0 (initially its 8 ). In the body of the loop we calculate the factorial as thus on the first run factorial is 1 and number is 8 so factorial = factorial * number;, evaluates as 1 = 1* 8 which is still 8 and so the number 8 is stored in the factorial variable, i.e. factorial = 8 The next statement --number, decreases the value of number by one making it 7 On the next run of the loop the control-condition (number > 0) still holds true as number is 7 and thus > 0 so the loop is executed again and - factorial = factorial * number;, evaluates as 8 = 8* 7, given 56, and this is stored in factorial. The statement --number, decreases the value of number by one (again) making it 6. This process runs again and again updating the factorial variable and decreasing the number on each successfull run until the condition (number > 0) isn't true any more and the looping stops. The final value stored in variable factorial is our answer and is printed to the output |
while and for loops are termed entry condition loops, this is due to the fact that their condition(s) for looping is checked each time before the loop is executed, the examples seen so far are quite basic, as we proceed we would encounter more complex (and sometime strange) usages of loops. so lets see some more while loops |
lets see some basic examples
in the first example we declare a variable index and set its value to 1, then the control-expression index < 5 is evaluated, so far as this expression returns a positive/truthful result the loops body i.e. the printf statement is executed. in the second example the variables are the same the only difference is the control-expression --index < 5, this statement uses a pre-decrement to decrease the value of the variable index by one each time the loop is run, however this example prints a never ending line of Good morning's, this is termed infinite looping and is usually an error condition, before i explain while the loop runs infinitely can any one take a stab at the explanation And also the second example shows a crucial point, whenever you craft loops, make sure there's some condition that would cause the loop to terminate and not just run endlessly, except you actually wanted it to (this could be valid ins some kind of programs) |
The while loop is another general purpose loop, and is renowned for its compactness and ease in handling complex loop expressions the basic form of the while loop is
The control-expression or statement parts could be simple or complex statements The basic operation of the while is straight forward -- the loops control-expression is evaluated first and if the result of the evaluation is non-zero/non-false the statement contained in the loop's body is executed, this process is repeated until the control-expression fails |
[size=16pt]while[/size] loops |
In the last example you'll notice the for loop's body isn't enclosed in braces {} generally if the body of a loop is contained wholly one one line the braces can be excluded |
Here we show that more complex expressions can be used for any of the values in a for loop
This loop prints the values of x and of the algebraic expression ++x * 5 + 50 . The output looks like this: 1 55 2 60 3 65 4 70 5 75 While we haven't discussed operator in-depth the expression (++x * 5) + 50 should be trivial to comprehend The variable (x) is first initialized to 1 in the loop's initialization statement. Then in the update statement it is per-incremented by one then multiplied by five, and the result added to 50 |
The update statement in for loops do not need to be increased/decreased by one, any arbitrary number or expression would do
This would increase n by 13 during each cycle, printing the following: 2 15 28 41 54 In the above program, the variable n is initialized with the value 2, and then the loop checks runs only if the value of variable n is less than 60, and then after each run of the loop n is increased by 13, this process continues till the test condition n < 60 fails and the loop is then terminated |
dhtml18:dhtml18 ![]() |
mnairaland:am already doind that bro, see the last few post's, yeah i know i shoulld have started with d basics,make una no vex, currently on for loops, and sorry to everyone for not posting anything on-topic for a feew dayz now bn away from my system and i no fit type long post on phone, would continue tommorow (if Nepa coporates that is) |
and so this ict-expo thing ends today and the bloody organizers no even give more info regarding the change of date of the Hackathon, not even a reason, smh for them ![]() |
Booyakasha:its undoubtedly a great reference still downloaded the entire site last week for offline veiwing cuz i lost my previous offline copy, twas quite large tho, a little over 600mb but at least i gat the entire site whenever i need to look somthn up |
godofbrowser:i hav been a web-dev for years so trust me when i say W3cschools is too soft core,there's just too much they left out of their tutorials, to me.its best for reference (and i still use it for that) but you'll need better tutorials to get the full gist of many web-dev languages u say u built a Cgpa calculator, bro thats basic stuff resarch into writing say a natural language parser in JS then you'll see w3c has only taught you the rudiments and at best let you know the syntax |
this evening we look at linking using the <a> tag and how to style links |
KvnqPrezo:such is only neccessary in XHTML and other XML type documents, u however do it this way <![CDATA[ //code goes here ]]> so the XML parserr can ignore those sections. using <!-- --> (HTML commennts) is meant to block sccripts from browsers that do not understand javascript which is rare nowadays |
KvnqPrezo:the way you formulate your script-tag has nothing to do with HTML5, and also the language attribute isn't neccesary cause browsers by default woyld assume JavaScript, again the way you wrote the type attribute isnt exactly right, it should be type="text/javascript", dont camel-case the word |
today was supposed to be the day of the hackathon and i was just leaving home for the venue, na im i get call saying its no longer holding today that they would keep all contestants informed, what the hell is wrong with Nigeria and planning |
the GCC compiler package in the link i pasted would download as a 7z archive so you'll need a tool such as WinRar (http://www.rarlab.com/download.htm) or 7-zip (http://www.7-zip.org/download.html) to extract the contents, after extracting ( i only recommend extracting to the root of your C: drive, any other location should do) you then setup Codeblocks to use the GCC compilers from the Settings->Compilers menu Then you can directly compile from the build menu |
furthest:bro i pasted the links for both 32bit and 64bit GCC compilers on page 1 and inatructions on setting them upe with code blocks, aanyway here are the links again if you are on 32bit windows get this file here https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/dongsheng-daily/6.x/gcc-6-win32_6.1.1-20160715.7z/download and for 64bit systems get this https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/dongsheng-daily/6.x/gcc-6-win64_6.1.1-20160715.7z/download |
bestiyke:guys can we end this matter |
I might or might not be posting much for the next few days, as i got some waka waka to do, please if anyone has got questions up to this point?? |
bestiyke:Myopic?, bro, me just dey catch fun nah. shu, but then again its not a standard way guys address each other for our 9ja |
dhtml18:LOL, i thought i was only joking anyway.. ![]() |
By the way my good people them, when learning any form of programming, don't rely only on the source you are learning form, learn to digg deeper on your own (Google is your friend here), how fast and well you'll learn truly depends on how enthusiastic u are and how far you are willing to research further on your own |



