CampusLearn
← BIT 203 Web Application Development

HTML and CSS Fundamentals

Notes

Meaningful document structure Hypertext Markup Language, or HTML, describes the meaning and structure of a web document. Headings organise topics, paragraphs contain prose, links connect resources and forms collect input. Semantic elements such as main, nav and button communicate purpose to browsers and assistive technologies. Associate each form control with a visible label, provide meaningful alternative text for informative images, and maintain a logical heading hierarchy. Browser validation improves usability, but the server must independently validate submitted data because a client can bypass or modify any browser restriction. Presentation and responsive layout Cascading Style Sheets, or CSS, controls presentation through selectors, declarations and rules for resolving competing styles. The box model consists of content, padding, border and margin. With border-box sizing, the specified width includes content, padding and border, simplifying layout calculations. Flexbox arranges items along a main axis, while Grid supports coordinated rows and columns. Responsive design adapts layouts to available space using flexible dimensions and media queries. Test keyboard access, contrast and text enlargement alongside screen size because a visually attractive page may still exclude users. Practical example A Nairobi e-commerce startup displays product cards in a container 960 pixels wide. Each card uses border-box width 300 pixels, including 16 pixels of padding and a 2-pixel border on each side. Its content width is 300 minus 32 minus 4 = 264 pixels. Three cards and two 24-pixel gaps occupy 3 times 300 plus 48 = 948 pixels, leaving 12 pixels. On a 360-pixel phone, the layout changes to one flexible column rather than forcing three fixed cards into the viewport. Labelled quantity controls also help customers using keyboards or screen readers.

Quiz

1. What is the content width of the 300-pixel border-box card described?

2. What does semantic HTML primarily communicate?

3. Why must a server repeat form validation?

Sign in to submit and securely grade your quiz.