Editing Font Size and Style within a internal link - html

I have recently learnt how to create a html internal link; allowing my members to jump down the page to specific information.
However the coding I have used is set at a standard size and font. I would like to edit the font size and font style of the topic title.
a name="category-one">Under 6's</a>
Above is my current coding; how can I increase the text of the title "Under 6's"?

you can use inline style in a element this way
<a name="category-one" style="font-size:18px; color: green;" >Under 6's </a>

You should always use css for styling.
You can give each element a separate class and style those accordingly.
Under 6's
In css:
.title a{color: blue;}

There's much more efficient ways to refer to an object.
class is versatile in that you can apply it multiple times, this is the prefered way.
id is not as versatile because each id must be unique so your'e limited to just styling a single element.
a[name='category-one'] {
font-size: 16px;
font-family: "Palatino Linotype";
}
a.category-two {
font-size: 1em;
font-family: "Source Code Pro";
}
a#category-three {
font: 1rem;
font-family: "Verdana";
}
a:hover {
font-size: 20px;
font-family: "Arial";
}
<a name="category-one">Under 6's (refer by name attribute)</a>
<a class="category-two">Under 7's (refer by class attribute)</a>
<a id="category-three">Under 8's (refer by id attribute)</a>
There's three ways to apply styles:
The prefered way is using a separate file (e.g. style.css) and then pointing to it from your main page:
<link href="http://www.example.com/css/style.css" rel="stylesheet"/>
It may be more work to maintain a separate file, but it can be used by multiple pages on your site.
Another way to provide CSS rules is to use the <style> element and place that before the closing </head> tag. Although faster when loading, the code will become difficult to manage and it can only be used by one page (the page the <style> is on.)
....
<style>
.foo { height: 60px; }
....
</style>
</head>
Inline styles are discouraged and should be used sparingly if at all. They are limited to only the element they are on and harder to locate and debug. One advantage is that the rules will take priority over all other non-inline style rules (or should I say, most of the time, because there's always a bug or edge cases).
<a name="category-four" style="color: red; background: #000;">Under 9's</a>

Related

How to style labels in a css file

Home
Read Here
I made four labels in my HTML code with different texts. But I don't know how to specifically pick one to style in my css file.
Unable to help fully without seeing your code but I would say apply an id="name_of_element" to each text element.
Then in you .css file use #id-name-here to apply styling to each text element individually.
#element_id_here {
color: blue;
font-weight: 600;
padding: 5px;
margin-top: 10px;
}
You can change the parameters to suite your needs but these are just an example.

CSS Styling approach

Which is the more preferred style of CSS styling in the industry?
Create classes for each attribute (like bootstrap), then attach the classes in HTML. For example:
HTML: <p class="text-white text-bold"> John Doe </p>
CSS:
.text-white {
color: white;
}
.text-bold{
font-weight: bold;
}
Add usually 1 class per html tag. For example:
HTML: <p class="description"> John Doe </p>
CSS:
.description {
color: white;
font-weight: bold;
}
Which is overall the better approach?
Based on my experience, I am usually doing the first approach. Reason for this is for code reusability, because you can still apply it to any elements that would be needing the same styling.
Always name your classes as generic as possible.
Example:
.hand { cursor:pointer; }
.padding-5 { padding:5px; }
.padding-left-5 { padding-left:5px; }
.border-1 { border:solid 1px #f00; }
.corner-1 { corner-radius: 3px; }
.margin-auto { margin: auto; }
.bgcolor-1 { background-color: #b2e8ff; } /* light blue */
.bgcolor-2 { background-color: #FFF3CD; } /* light yellow */
.table-hover tr:hover { background-color: #eaf6ff !important} /* overide bootstrap's table hover */
Don't do it like that. Having only one style in a class will get confusing it would more so than putting all the styles for a element in its tag as
<div style="border:solid 1px #333; color:#0f0; etc;
What I found is a better approach is to create a generic type group class as
.boxStyle1{
border:solid 1px #333;
color:#0f0;
}
.fontStyle1{
font-family: Arial, ...;
font-size:.9em;
}
And using them in different elements such like
<div class="boxStyle1 fontStyle1">
Using the group style approach lets you apply the same theme for different elements depending on what look you want. This way its less confusing when you want to change the look of your site.
I learned something similar to the second method. You specify style class/id names indicated in the HTML tag, <p class="sample">...</p>, then outline those details in a separate CSS file:
.sample {
font-family:Arial;
font-variant:small-caps;
color:#FF0;
text-align:center;
}
One of the primary benefits is efficiency. With all of the style details in one file, it's loaded once for your site visitor and the information is available to render for every page of your website that they visit. Thus reducing the amount of time it takes for your pages to load and improving the user experience. It is also more efficient for you while you are coding your pages. Once you decide how you want your website to look, you can create all of the element styles and reference it as often as necessary, greatly reducing the time to create your site. (Note: this does not mean that you can not or should not have more than one CSS file.)
There are occasions when you want to list more than one class/id style for an element: <div class="sample sample2"></div>. Sometimes it makes sense to do it, however, seperating each individual style into it's own class/id is superfluous. Learn to group everything for your class="sample" in your CSS .sample (class).
The W3C, Mozilla, and the online courses offered through edX all support this method as well. Which should clearly indicate that it is the "industry standard".
W3C Starting with HTML + CSS
Mozilla's Introduction to CSS Layout
edX's CSS Courses

Using div inside p tag loses my styles

I have a page where I want to represent a URL to the student (but not have browser defaults, like changing to a pointer on hover, etc), and I am losing my styles by wrapping the text in div. I have
index.html:
<p>
we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
<div style="color:blue;">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>
styles.css:
body {
background: #f0f0f0;
width: 80%;
margin: 0 auto;
}
h1 {
text-align: center;
margin-top: 35px;
margin-bottom: 60px;
}
p {
font-size: 20px;
font-family: sans-serif;
}
.cl {
margin: 38px;
padding: 25px;
background: #f8f8f8;
font-family:DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New;
font-size: 12px;
}
.fake-url {
color: blue;
}
Most recently I had tried using .fake-url in the div,
<p>
we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
<div class="fake-url;">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>
and after that I did
p, p div {
font-size: 20px;
font-family: sans-serif;
}
I'd like to suggest you to use a span instead of a div, div are block elements in the other hand spans are inline elements and fit better in the context you want to use it.
And as someone mentioned above, you have an extra ; inside the div's class
<div> elements don't belong inside <p> elements. Browsers usually rework this so that the <p> element is closed just before the <div> element and then opened again just after. This effectively splits your paragraph into two pieces, one before the <div> and one after.
Instead, use a <span> or, more appropriately, a <a> element.
MDN has an entry that mentions this. Specifically, in the section marked "Tag omission", it mentions that if an opening <p> element is followed by an opening <div> element then the paragraph is implicitly closed.
<p>
we can see Django made us our first url, the admin. Since this file is our url entry point (as declared in `settings.py`), if our hostname is "www.eat-it.com",
<div class="fake-url">www.eat-it.com/admin</div> is now available. We'll talk more about Django admin later.
</p>
Just removing the ; from the class name in the div will fix it.

Is there a performance gain in CSS for grouping relating properties under one selector vs two?

I'm using SCSS/COMPASS on a project(personal web design framework) and am considering if this way of modularizing code will hinder performance at all.
I want to do this so that I can set my typography in one .scss file and my positioning (for this element and others) in another .scss file. This would allow me to split up my aesthetics from positioning. Good for the way I prefer to think, especially if the website gets bigger. Problem is by doing this, I now am selecting the same element multiple times & in different places.
Would this technique cause issues (page load speed, etc) at any website traffic levels?
Here is the code, I have my font style properties & my positioning properties for my:
<header class="header">
<h1>Title</h1>
</header>
split up as follows:
header h1 {
text-shadow: 1px 1px 1px #000;
color: navy;
font-weight: normal;
font-size: 1em;
}
.header h1 {
margin: 0 0 9.5% 0;
text-align: center;
}

CSS overriding CSS and jQuery UI

So I have a regular CSS/HTML website for my upcoming book. It has a section called Bonus Features for extra articles that I’ve written. They pop up using jQuery UI that reads from external HTML pages.
Because I want the titles and dates… i.e.
Hello World
May 6, 2011
…to be very close together, instead of your usual gap, I’ve created a separate CSS stylesheet (dialog.css).
body {
font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 12px;
}
h1 {
font-weight: bold;
margin: 0;
}
h1 + p {
margin: 0;
}
h2 {
margin: 0;
}
h2 + p {
margin: 0;
}
p {
font-size: 14px;
line-height: 18px;
margin-bottom: 10px;
margin-top: 0px;
}
Unfortunately, dialog.css seems to be overriding default.css (for the website) because whenever I open then close the pop-up, the text on the Bonus Features page clutters together, reading from dialog.css, until a browser refresh.
Is there a way to prevent this from happening, like a special HTML or CSS code?
Thanks.
It sounds like dialog.css is being loaded in the main page's scope.
if your dialog is built like this:
<div id="dialog">
<!-- content -->
</div>
then you can make your css like this:
#dialog h1 {
font-weight: bold;
margin: 0;
}
and those properties will only apply to elements within an element of id #dialog
Sometimes, it can be as simple as minding the order that the css loads. The last one in order defined will generally take precedence. Yes, there are exceptions, but as a rule of thumb, put your most customized CSS file at the end of a series of CSS declarations, while loading things like jQuery UI's css first.
use firebug (or something similar) to find out how this property is set. to override this rule you need to use the same exact selectors or more powerful. thats the way CSS works and thats where the name came from.
also you may try adding !important after each rule.